i'm working on jquery custom validation of multidimensional select box. i'm trying access name of multidimensional select box element:
<select id="start_time_195" class="myclass" name="start_time[195]">
using following code snippet:
$.validator.addmethod("my_method", function(value, element) { console.log(element.name); }, "this text displayed validation message.");
the console output start_time[195]
but want key 195
out of element name. there direct way value?
the alternate way think use .split()
function, bit lengthy process.
thank help.
add in data @rory mccrossan suggested. can add id in attribute data-id = 195
$(this).attr('data-id');
if dont't want fetch id
var id =$(this).attr('id'); getid = id.split("_"); getid[2] // value
Comments
Post a Comment