JQuery introduces the difference between val and atrr of 'value' assignment

  • 2020-03-30 04:01:16
  • OfStack

When I was working on the project, the data that I passed in the background was assigned to a text box, and through the Google browser,

I found no change when I modified it. At last, I checked the reason. It was the difference between val and atrr("value") in jQuery.

Therefore, it is summarized as follows:
The use of val() and atrr('value') in jquery, assuming that there is a default value, if the value is assigned with val(), then Google cannot get the latest value when the modification is worthwhile, but ie can,
If there is a default value for atrr('value'), then both ie and Google will be able to get the latest changes when the change is worthwhile. The current tests on ie and Google are not tested by other browsers. Ha ha


Related articles: