hello friends,
i want to get the class name from li tag
for example

<ul>
<li class="itme11"></li>
<li class="itme21"></li>
<li class="itme31"></li>
<li class="itme41"></li>
</ul>

and i want to access the class item31
how do i get the class name item31 with javascript??

plz help me to solve out

Use JQuery my friend.

They have the best selectors.

//To set the innerHTML of <li class="item31">
// # is the ID select
// . is the class selector

$('.item31').html('My new HTML');

JQuery it's a very useful JS lib, learn it and it'll save u time =)

Seeya.

Use JQuery my friend.

They have the best selectors.

//To set the innerHTML of <li class="item31">
// # is the ID select
// . is the class selector

$('.item31').html('My new HTML');

JQuery it's a very useful JS lib, learn it and it'll save u time =)

Seeya.

@Seeya Thanks to taking intrust but the problem is i will use this code in joomla site to modify some part of the code, and if i use jquery then it conflicted with mootools, even i used jQuery.noConflict(); but still it conflicted with mootool, thats why i used javascript, but now i did that with some other logic without javascript, but still i want to do this cause i am not good in javascript, but just know some jquery..

You can have jQuery + Mootols without conflict, or jQuery with Prototype without conflict, etc. Apart from the noConflict(), have you tried having all jQuery stuff (lib, plugs, code)loaded first, then the rest of js?

To avoid conflict, use "JQuery." insted of "$."

To avoid conflict, use "JQuery." insted of "$."

I tried jQuery instead of $ but the problem was i call the jquery.min.js file form the ajax.googleapis.com, i did it separately into my joomla directory, and then it worked with jQuery.noConflict(); and used jQuery instead of $ without any conflicting with mootools..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.