MGames MGames - 11 months ago 92
HTML Question

Jquery- How to use contains here?

How would I use contains to search for a placeholder to search for the word "name" and set the value rather than search the exact value of a placeholder.

Here is the html:

<input autocorrect="off" placeholder="full name here" id="order_billing_name" name="order[billing_name]" size="30" class="" type="text">


How would I use contains to search for "name" and set the value rather than searching for the exact value "full name here"

$('[placeholder="full name here"]').val('name here');

Answer Source

You can use attribute value contains selector

$("[placeholder*=name]").val("name here")
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js">
</script>
<input autocorrect="off" 
       placeholder="full name here" 
       id="order_billing_name" 
       name="order[billing_name]" 
       size="30" 
       class="" 
       type="text">

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download