I am trying to apply css to a label when input fields are focused using jQuery, but it doesn't seem to work. The contact form is loaded inside an iframe. If an iframe is not used, it works fine - check this jsfiddle: http://jsfiddle.net/nN3w2/ (if the iframe doesn't load the server might gone down - but the code is there for you to see).
The iframe and the contact form are located on the same domain. The contact form is included using php to my website.
<script type="text/javascript">
jQuery(document).ready(function($) {
$("#iframe").contents().find("input").focus(function() {
$("#iframe").contents().find("label").css('opacity','0');
});
});
</script>
non-iframe
<script type="text/javascript">
jQuery(document).ready(function($) {
$("input").focus(function() {
$("label").css('opacity','0');
});
$("input").focusout(function() {
if($("input").val() ==="" ) {
$("label").css('opacity','1');
}
});
});
</script>