tags:

views:

32

answers:

1

hi i am using mootool.js and i want to use two buttons (show/hide).There is li on my html page id as list.This is in loop (200 li has same id).i want to show hide images on onclick function of buttons.for this i have made a javascript in which i have send the value show and hide and write this line in javascript $('li#list').set('class','hide') and made a css as hide set display as none but this is produce a error that li#list is null tell me where i am wrong

<li id=list>
 <span>img tag</span>
</li>
<li id=list>
 <span>img tag</span>
</li>

. . 200times

+2  A: 

Hey it appears you are using $$ and $ incorrectly. The correct use is $('idWithoutHash') and $$('.cssSelector'). $ returns a single element, $$ returns an element collection. Also you can add and remove CSS classes using the Element.addClass and Element.removeClass methods, this helps if you want to multi-class an element.

Nic Bell