1

I want to select a div with class textbox and also has a data-title that starts with the string in the variable dt. Something like this:

var $theboxes = $(".textbox[data-title^="+dt+"]");

I've tried this but it causes an error in jquery. What's the right way to do this?

4

1 回答 1

1

I think you actually need to quote the attribute value.
Try something like this:

var $theboxes = $(".textbox[data-title^='"+dt+"']");
于 2012-12-15T18:04:45.900 回答