如何使用jQuery区分以下类型的ID?
id="sectionId_1"
id="sectionId_1_1"
我尝试了以下方法:
$(".row").find("input[id^='sectionId_']").each(function(){
========
There are two types of pattern
1. id="sectionId_'+i+'" (section) where i can be 0,1,2 etc
2. id="sectionId_'+i+'_'+j+'" (subsection) where i and j can be 0,1,2
etc
for the second case i & j relationship is somewhat like nested for loop
I need to get the values of section and subsection separately in
different .each loop and put it in separate array as well
答案 0 :(得分:-1)
我为查询打了个小提琴。
https://jsfiddle.net/op5uv6mg/5/
$(document).ready(function () {
$("div").find("input[id^='sectionId_']").css("border", "1px solid green");
$("div").find("input[id^='sectionId_1_']").css("border", "1px solid pink");
});