user625079
user625079

Reputation: 125

selectval = jQuery( selected ).attr("value") only getting first number

why am i only getting getting 6356 into #id_OnPage? there are of course more LI.

I'm getting the rigth li, but only the first number..

<ol id="pageselect" class="ui-selectable">
        <li value="6356,6145,6296,6211,6147,6149,6152,6155,6158,6160">page 1</li></ol>

jQuery( ".ui-selected", this ).each(function(i, selected) {
  jQuery(this).siblings().removeClass("ui-selected");
  selectval = jQuery( this ).attr("value");
  jQuery('#id_OnPage').val(selectval);
});

thanks for any help

Upvotes: 0

Views: 643

Answers (1)

TNC
TNC

Reputation: 5386

A couple of notes, <li value=""> is deprecated, and not supported by HTML 4+. Since you're using jquery already, you can just store your data (via jQuery) in your li. So, you could do something like:

HTML

<li id="page1">page1</li>

jQuery

// Store
$('#page1').data('value', '6356,6145,6296,6211,6147,6149,6152,6155,6158,6160');

Then you can access it, like:

$('#page1').data('value')

Upvotes: 3

Related Questions