Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JQuery - go down with selector name

Tags:

jquery

I created this code:

$("input[name*='Gridview1$ctl02']").each(function () {
   if(this.type == 'checkbox'){
       if(this.checked == true){
           alert("test")
        }
       else
        {
           alert("test2")
        }
    }
})

Its good when I write this $("input[name*='Gridview1$ctl02']") but I need array of ct101,ct102,ct103

enter image description here

I need Something like this:

$("input[name*='Gridview1']").find("ct").each ...
like image 729
Rafał Developer Avatar asked Sep 04 '26 00:09

Rafał Developer


1 Answers

You can simple create a selector to match any element where their name starts with Gridview1:

$("input[name^='Gridview1']").each(function () {if(this.type == 'checkbox'){if(this.checked == true){alert("test")}else{alert("test2")}}})

Alternative if you want only text inputs:

$("input[name^='Gridview1'][type='text']").each(function () {if(this.type == 'checkbox'){if(this.checked == true){alert("test")}else{alert("test2")}}})
like image 191
Alex Char Avatar answered Sep 05 '26 13:09

Alex Char