Split is a javascript web API method(Here) and does't have anything to do with jQuery.
In your case it will split the value of the id attribute if it does have a underscore (_
). split returns and array , so [n] (n being any index of the array) , will return the value of the given index of the array. Eg. in the below example am
is returned , which has an index of 1
.
So ,
$("#i_am_a_href").attr('id').split('_') // will return [ "i", "am", "a", "href" ]
$("#i_am_a_href").attr('id').split('_')[1] // will return 'am'
See example below
var row = $("#i_am_a_href").attr('id').split('_');
console.log(row);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<a href="#" id="i_am_a_href">Anchor Tag</a>
Pro Tip : you also probably want to learn the difference between prop()
and attr()
, and when to use which (LINK HERE)