jQuery .val() method

0 votes
283 views
added Feb 9, 2018 in jQuery by LC Marshal Captain (25,790 points)
edited Aug 16, 2018 by LC Marshal

Get value for selected option

var property_type = $('#property_type option:selected').val();

 

2 Responses

0 votes
responded Apr 2, 2018 by LC Marshal Captain (25,790 points)

Add value to button upon click

<p>Name: <input type="text" name="user"></p>
$("button").click(function(){
    $("input:text").val("Get this value upon click);
});
0 votes
responded Oct 31, 2018 by LC Marshal Captain (25,790 points)
// if value is empty, do this, else do that
$requestCommentTextarea.on("input", function() {
    if ($requestCommentTextarea.val() !== "") {
      $requestMarkAsSolvedButton.text($requestMarkAsSolvedButton.data("solve-and-submit-translation"));
      $requestCommentSubmitButton.prop("disabled", false);
    } else {
      $requestMarkAsSolvedButton.text($requestMarkAsSolvedButton.data("solve-translation"));
      $requestCommentSubmitButton.prop("disabled", true);
    }
});

 

lazacode.org - Malaysia's programming knowledge sharing platform, where everyone can share their finding as reference to others.
...