views:

584

answers:

2

Hi,

Following is my code, i want to hide a li tag depending on its content.

dom.find('ul#overlay_opt li').click(function(){
  if($(this).attr('class') != 'deactive'){
   var content = $(this).text();
   if(content == 'none') dom.find('#secondary_para').hide();
   else dom.find('#secondary_para').html($(this).text()).show();

  }
});

My html is

<ul id="overlay_opt">
        <li class="deactive">none</li>
 <li>Requests</li>
 <li>Impressions</li>
 <li>Clicks</li>
 <li>Earnings</li>

</ul>

Problem is, in ie variable and string comparison is happening.

i.e "if(content == 'none')" every time it executes as false.

A: 

The reason "if(content == 'none')" is returning false every time is because the only "li" that has the text of "none" has the class of "deactivate" which you are checking in the if block above the statement.

I'm not really sure what you are trying to do here. Please explain more.

T B
Thanx for your response. here is screenshot http://www.freeimagehosting.net/uploads/65dde35e6c.gifOn click of 'li', its content has to updated in a span(just check screen shot), mean time its class changes to 'deactive', but onclick of 'none', span tag has to hide. So i'm checking the content of li to update span / hide span.
vinay
A: 
I added 'id' for none li, using id, i am hiding span.

<ul id="overlay_opt">
        <li id="none">none</li>
        <li class="deactive">Requests</li>
        <li>Impressions</li>
        <li>Clicks</li>
        <li>Earnings</li>

</ul>

dom.find('ul#overlay_opt li').click(function(){
                if($(this).attr('class') != 'deactive'){
                        var content = $(this).text();
                        if($(this).attr('id') == 'none') dom.find('#secondary_para').hide();
                        else dom.find('#secondary_para').html($(this).text()).show();

                }
});
vinay