javascript - Place holder is not working -
place holder not working in ie-9,so used below code place holder.
jquery(function () { debugger; jquery.support.placeholder = false; test = document.createelement('input'); if ('placeholder' in test) jquery.support.placeholder = true; }); // adds placeholder support browsers wouldn't otherwise support it. $(function () { if (!$.support.placeholder) { var active = document.activeelement; $(':text').focus(function () { if ($(this).attr('placeholder') != '' && $(this).val() == $(this).attr('placeholder')) { $(this).val('').removeclass('hasplaceholder'); } }).blur(function () { if ($(this).attr('placeholder') != '' && ($(this).val() == '' || $(this).val() == $(this).attr('placeholder'))) { $(this).val($(this).attr('placeholder')).addclass('hasplaceholder'); } }); $(':text').blur(); $(active).focus(); $('form:eq(0)').submit(function () { $(':text.hasplaceholder').val(''); }); } });
when taking value of test,it shows null.how can details of input tag?
i think
if ($.browser.msie) { $("input").each(function () { if (isnull($(this).val()) && $(this).attr("placeholder") != "") { $(this).val($(this).attr("placeholder")).addclass('hasplaceholder'); $(this).keypress(function () { if ($(this).hasclass('hasplaceholder')) $(this).val("").removeclass('hasplaceholder'); }); $(this).blur(function () { if ($(this).val() == "") $(this).val($(this).attr("placeholder")).addclass('hasplaceholder'); }); } }); }
Comments
Post a Comment