Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

jQuery selector not working in IE7

 
Manju R Sankar
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JQUERY selector not working in IE7 but worrking in IE8 and all other browsers..


Example:::
$(th).find("div[ID='CONTAINER_TYPE'][CLASS$='enableBtn']").attr('TYPE');
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
why would you not use # to select an element by id? It is so much faster than an attribute selector.

Also do you have more than one element with the same id?

Have you debugged to see where the code fails?

Eric
 
Manju R Sankar
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I placed Id just for an example..Instead of Id i used user-defined attribute... like<span FW="CONTAINER_TYPE">

i did not have more than one attribute with same Id...
I have more than one attribute with same user-defined attribute...
<span class="adsblockElement adsflLeft adscursorPointer adspieGraphSelect" FW="CONTAINER_TYPE" TYPE="PIE" ></span>
<span class="adsblockElement adsflLeft adscursorPointer adsbarGraph" FW="CONTAINER_TYPE" TYPE="BAR" ></span>


It is working fine for selecting items with one selector.
But when we use two selectors($(th).find("span[FW='CONTAINER_TYPE'][CLASS$='enableBtn']")) to select an item it does not works in IE7
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64843
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The HTML5 convention (which should be used even if still using HTML4) is to name custom attributes in lowercase, and prefixed with data-.

Also, I have no idea what "FW" is suppose to stand for ("frankincense wardrobe"?), so use real words for readability; e,g, data-frankincense-wardrobe rather than FW.

I'm not sure about the IE7 issue -- I don't have an instance to test in. Do they work individually? How about when using .add()? .filter()?
 
Manju R Sankar
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HTML:::
<div class="adsflLeft" style="display:block" id="TYPES">
<span class="adsblockElement adsflLeft adscursorPointer adspieGraphSelect" FW="CONTAINER_TYPE" TYPE="PIE" ></span>
<span class="adsblockElement adsflLeft adscursorPointer adsbarGraph" FW="CONTAINER_TYPE" TYPE="BAR" ></span>
</div>


JQUERY::::
alert($('#TYPES').find("span[FW='CONTAINER_TYPE'][CLASS$='Select']").attr('TYPE'));

It returns 'undefined' in IE7...
When we use multiple selector like above([FW='CONTAINER_TYPE'][CLASS$='Select']).....
 
Manju R Sankar
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Finally i got it..
It is a case sensitive issue...

I used 'class' insteadof 'CLASS' and it worked out.

Thanks for reply.......
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64843
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
While IE7 should not have tripped up like that, it'd behoove you to follow conventions and use all lowercase for attribute names and the like, and to follow the other conventions I mentioned previously.
 
twan arkink
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Manju R Sankar wrote:Finally i got it..
It is a case sensitive issue...

I used 'class' insteadof 'CLASS' and it worked out.

Thanks for reply.......


Thanks for posting the solution it helped me out pretty well
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic