aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes jQuery selector not working in IE7 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "jQuery selector not working in IE7" Watch "jQuery selector not working in IE7" New topic
Author

jQuery selector not working in IE7

Manju R Sankar
Greenhorn

Joined: Mar 14, 2012
Posts: 18
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

Joined: Nov 08, 2001
Posts: 15376
    
    6
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

Joined: Mar 14, 2012
Posts: 18

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

Joined: Jan 10, 2002
Posts: 61180
    
  66

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()?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Manju R Sankar
Greenhorn

Joined: Mar 14, 2012
Posts: 18
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

Joined: Mar 14, 2012
Posts: 18
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

Joined: Jan 10, 2002
Posts: 61180
    
  66

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

Joined: Jan 14, 2013
Posts: 1
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: jQuery selector not working in IE7