MGames MGames - 2 months ago 20
HTML Question

JQuery Code For Selecting Select Option & Clicking Button Not Working?

Hi I'm tring to select the Large size and click the button from a website. I have the html code in fiddle as well as the jquery code I tried. I've tried these (below), but it doesn't seem to be working. What did I do wrong?

This is for selecting the Large size:

$('select[name="size"] option').filter(function () { return $(this).html() == "Large"; }).attr("selected",true);

This is for clicking the button:


Here is the fiddle for what I've tried:

-Thank you


try this:

$('#size').val($('#size option').filter(function(ind, el) {
  return $(el).text() === 'Large';