An application I'm working on at the moment had the need for me to select a group of elements (in this case they're divs) which all contained a common string in their id (in my case, the prefix for the div's id was 'content', so 'contentOne', 'contentTwo', etc).
I found a lot of people saying they way to go was to use \\S* as shown in sample One below, however I couldn't get it to work no matter how many variations I tried. I found a few other people who'd had the same problem as me – reassuring, but I'd quite like to know what we're overlooking. It's no major deal as I found a working alternative (code sample Two below), but I am a little curious as to why a few people might be running into problems using the first piece of sample code.
// One
$('#content\\S*').each(function () {
$(this).hide();
});
// Two
$("div[id^='content']").each(function() {
$(this).hide();
});
Anyone able to shed some light?
Posted on Thursday, February 12, 2009 1:38 PM |