DreamToCode
DreamToCode

Reputation: 291

add items to list via button click in jquery

I have a select list and need to append each selected value/text to a list on a button click. Here is some pseudo code

  $("#addButton").click(function () {           

            var selectedValue = "..."
            var selectedText = "..."

            //todo append each selected value & text
            //to an unordered list 
            //on submit of form read in via querystring selected
            //values and text from the unordered list

}); 

Any ideas?

Thanks

Upvotes: 2

Views: 6199

Answers (1)

Dipak
Dipak

Reputation: 12190

$("#addButton").click(function () {           

  var selectedVal = $('select').val();

  $('ul').append('<li>'+selectedVal+'</li>')

}); 

JSFiddle

Upvotes: 6

Related Questions