html - Jquery - Getting what actually is displayed in in text area -
we automating web tests , want validate in text area.
we want check showing user perspective. not matter if it's placed there placeholder or entered user/testcase. utilize html5 placeholder attribute.
$("textarea").text()
not give me if text has been entered via place holder.
tried $("textarea").val()
gives me same behavior using .text()
.
we write logic if ( text empty ) { @ placeholder }
feels wrong since not determine showing in text area. have alternative using logic. otherwise assume browser uses same logic implement in our test.
any ideas?
you mean html5 placeholder or placeholder added js plugin?
if case 1, guess can help:
var text = $("textarea").val() || $("textarea").attr('placeholder')
demo: http://jsfiddle.net/mjkfc/
jquery html
No comments:
Post a Comment