0

I append a HTML String to DOM

var str = "<input time=\"y\" name=\"changeDate\" type=\"text\"  class=\"input_M3_1\" id=\"textfield2\"  value='' dataType=\"Sino\"  >";

then append to dom and give a value;

$('#datadiv').append(str);
$("input[name='changeDate']").val('2014-8-15');

After this,I Use jquery selector

var date='2014-8-15';
$("input[value="+date+"][name='changeDate']");

Use the selector I just cannot find the it,And also I see it had add a new attribute name "realvalue".

1 Answer 1

1

val modifies the value property of the element not it's value attribute. For understanding the difference between attributes and properties you can check this question: Properties and Attributes in HTML

You can filter the inputs that have specific value property using filter method:

$("input[name='changeDate']").filter(function() {
    return this.value === date;
});
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.