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".

Yinbin Wang
  • 113
  • 6

1 Answers1

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;
});
Community
  • 1
  • 1
Ram
  • 143,282
  • 16
  • 168
  • 197