each - jQuery change text of a div if it's sibling contains a certain string of text -
so know how this, have multiple elements .each(function() running on, need make sure .modules contain spans "open 24 hours" trigger change of div "always open" , can't figure out doing wrong
if (thistimeset === 'open 24 hours'){ $(this).siblings("div").text("always open"); }
full working demo of app: http://jsfiddle.net/dxav7/ have ton of comments because pretty new js , need walk myself though doing (newb)
thanks can provide!
try this:-
problem here have many spans same text ===
doesn't match. using indexof find instance of atlease 1 mean "always open"
if (thistimeset.indexof('open 24 hours') > -1) { $(this).find('.openornot').text("always open"); }
another thing add not looking @ siblings of .module
instead child .openornot
. need use find descend down instead of looking @ peers using siblings
.
demo
edit:- per comment can select spans visible
var thistimeset = $(this).children("span:visible").text();
Comments
Post a Comment