javascript - How can I target a specific dom css class that has a specific inline style without using indexOf method -


the answer worked me here.
how can select element specific inline style?

$('div').filter(function() { return $(this).attr('style') == undefined || $(this).attr('style').indexof('display: none;') == -1 }). 

however, being jquery 2+ , wondering if there better method acheiving same result. wish change above method requires using indexof js method obtain value of -1 or 0 truthy falesy type return.

i have tried this: defaults select first style fines. , haven't figured way "filter" results specific class.

$("[style='display: block;']").css("color", "yellow"); 

i figured out jsbin. yea... share answer...

i used filter function above did attribute equals selector value .is method. here more info on jquery attribute equals selector. https://api.jquery.com/attribute-equals-selector/

here final code , jsbin 2 methods. let me know think. filter function looks if in "this" document class of .bottom-drawer there .is style value of "display: block". used style* give fuzzy approach of display: block or block;.
http://jsbin.com/coroxa/1/edit?html,js,output

$('.bottom-drawer').filter(function() {     return $(this).is("[style*='display: block']") === true; }).slidetoggle(620); 

this answer came , associated bin.

what project accomplished doing div drawer effect hides once drawer open - other 1 closes.

this wasn't method of using indexof wasn't option didn't seem intutive me purposes of selecting particular class or id's inline style. hope helps someone.

http://jsbin.com/coroxa/1/edit?html,js,output

$('.top.expand-accordian a').click(function(e){     e.preventdefault();     $(this).find('i').toggleclass('rotate');     $('.maui-drawer').slidetoggle(620);     $('.bottom-drawer').filter(function() {       //return $(this).attr('style').indexof('display: block;') === 0;     return $(this).is("[style*='display: block']") === true;     }).slidetoggle(620); });  $('.bottom.expand-accordian a').click(function(e){     e.preventdefault();     $(this).find('i').toggleclass('rotate');     $('.bottom-drawer').slidetoggle(620);     $('.maui-drawer').filter(function() {     //;return $(this).attr('style').indexof('display: block;') === 0;     return $(this).is("[style*='display: block']") === true;     }).slidetoggle(620); }); 

Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -