JSFiddle - React, Tailwind, and code Playground

by martinba

JavaScript

// creating form
$form = $('<form id="form"></form>');
$form.append('<input type="text" name="summer" value="hot" />');
$form.append('<select name="winter"><option value="cold">cold</option><option value="hot">hot</option></select>');

// output - these values are right
$('body').append("<p>original values: " + $form.serialize() + "</p>");

// change some value
$form.find("select option").removeAttr('selected');
$form.find("select option[value=hot]").attr('selected','selected');

// output - these are wrong
$('body').append("<p>changed values: " + $form.serialize() + "</p>");

// html output for check
$('body').append( "form after value has beeen changed: " + $form.html() );