jqueryでサイトを開発しています。たとえば、certian文字列を含むすべてのIDを選択したいと思います。
<div id="home_test_div">
</div>
<span id"agency_test_span">test</span>
ID内に文字列を含むすべての要素を検索したいtest
。特定の文字列で始まるID、または特定の文字列で終わるIDを検索する方法を知っていますか?私はこれまでこれをやったことがありません。私はそのコードで試してみます:
var search = "test";
$("[id$='"+search+"']").each(function(index) {
//some code
}