Is it possible to get multiple rel values from a single anchor in jQuery or generally in JavaScript without splitting the rel into an array?
For example, in the case of an anchor having two rel attributes delimited by the standard space:
<a id='a' class='b' rel='9 9' href='#'>Link</a>
I can get each by using:
$('.b').click(function(e) {
/* ... */
var rels = $(this).prop('rel').split("_");
$('form#form-stage-2 input[name=sleeve_t]').val( rels[0] );
$('form#form-stage-2 input[name=sleeve_n]').val( rels[1] );
/* ... */
});
But was wondering if something along the lines of might be valid?
$('.b').click(function(e) {
/* ... */
$('form#form-stage-2 input[name=sleeve_t]').val( $(this).prop('rel[0]') );
$('form#form-stage-2 input[name=sleeve_n]').val( $(this).prop('rel[1]') );
/* ... */
});
Nope, that’s not valid. You’ll have to split or do something similar. Not sure why you’re trying to avoid splitting, though, there’s no reason to.\
Edit: You could do this, which I don’t think is that bad at all.