Я пытаюсь разбить строку на основе определенного символа, а затем посчитать количество символов в каждой части.Есть ли способ сделать это?
Итак, у меня есть:
HTML
<a href="#" class="splitMe" title="Testing | this out">blah</a>
JQuery
$(document).ready(function() {
$('.splitMe').each(function() {
var item = $(this).attr('title');
var characters = item.split("|");
// Here's where I get stuck...
// Tried various methods of length, but haven't been able to get it to work
// Most recent version that failed miserably...
var first = characters[0].text().length;
var second = characters[1].text().length;
alert(first+" "+second); //Yields characters[0] is not a function
});
});