I am trying to get the placeholder attribute value and do a fadeIn with the label which has the placeholder value as a for value, but it’s not working.
HTML:
<html>
<body>
<form>
<input type="text" id="name" name="name" placeholder="First Name" />
<label for="First Name">First Name </label>
</form>
</body>
</html>
CSS:
input+label { display: none; }
Script
$(document).ready(function() {
$('input[type="text"]').click(function() {
var sd = $(this).attr('placeholder');
$('label[for^=sd]').fadeIn();
});
});
This works:
Try it http://jsfiddle.net/hwJy8/