0

I am developing a script that uses jQuery's val() and attr() but they seems not equal. They are both have the same text and length. When I compare both using IF statement they return false

var isSame = $(this).val() == $(this).attr("placeholder");
console.log('$(this).val() == $(this).attr("placeholder"): ' + isSame);

Looking on jQuery's API documentation on val() and attr() they both return String that is so I tried adding .toString() on both values but they doesn't work either.

Here is the screenshot using IE developer tools, emulated IE7

Here's the screenshot using IE

Some of us are still using old browsers such as IE7 so I need to use and test it on IE7

pvzkch
  • 341
  • 2
  • 4
  • 18
  • 1
    `$(this).val()` is returning the current value of the input, meaning anything typed into it. `$(this).attr("placeholder")` returns the value of its placeholder parameter. Are you typing in "Employee No" before evaluation? – Richard Foster Sep 02 '14 at 01:18
  • No! They both have the same text on window load – pvzkch Sep 02 '14 at 01:20
  • Here: http://jsfiddle.net/8w2xz1v8/show disregard the button and text input below. Press backspace or delete key using IE7 – pvzkch Sep 02 '14 at 02:35

0 Answers0