I have the following script:
http://jsfiddle.net/oshirowanen/gcYeB/
How do I split the string being displayed in the alert box into 2?
So I get an alert box 1 after the other.
The first alert showing
ABC
and the second showing
123
I have the following script:
http://jsfiddle.net/oshirowanen/gcYeB/
How do I split the string being displayed in the alert box into 2?
So I get an alert box 1 after the other.
The first alert showing
ABC
and the second showing
123
You can use the Javascript split function.
$('.test').live('click', function() {
var id = $(this).attr("id"));
var parts = id.split('_');
alert( parts[ 0 ] );
alert( parts[ 1 ] );
});
Split the id using the split method and the "_" as a separator. Then, repeat over each token ($.each) and alert its value.
$('.test').click(function() {
$.each($(this).attr("id").split("_"), function(key, value) {
alert(value);
})
});