In-field labels plugin not working [closed]

匿名 (未验证) 提交于 2019-12-03 01:01:02

问题:

I am trying to use the In-field labels plugin on the contact form of my webpage, but the script is not working (the in-field labels don't appear).

Also my form has positioning problems that I have been trying to work with for a while but in vain. Here is my code:

$(function(){     $("label").inFieldLabels(); }); 
<form action="" method="get" name="contact-form" accept-charset="utf-8">     <fieldset>     <p>         <label for="name">Name</label><br />         <input type="text" name="name" value="Name" id="name">     </p>     <p>         <label for="email">Email</label><br />         <input type="text" name="email" value="Email" id="email">     </p>     <p>         <label for="company">Company</label><br />         <input type="text" name="company" value="Company" id="company">     </p>     <p>         <label for="message">Message</label><br />         <textarea name="message" id="message">Message</textarea>     </p>     </fieldset>      <input type="submit" value="Submit" id="submit-btn" />     <input type="reset" value="Reset" id="reset-btn" /> </form> 

回答1:

I see you used the following code for textarea :

<textarea name="message" id="message" value="Message"></textarea> 

but

<textarea id="mytxtarea"></textarea> 

has no value property. if you want to add text within textarea then try with this

<textarea name="message" id="message">Message</textarea> 


回答2:

You need to get rid of the values of all inputs for this to work. They should be value="".

Using IE 9 Developer Tool, I see that you have the following CSS showing up for the <p> tag around the input fields:

body#contact .content #middle #right-col #form p {  left: -300px; top: 22px; color: #aaaaaa; position:relative;  } 

Get rid of that -300px. In IE it pushes the input fields off the form.

Edit: Okay, I think I've fixed it! Get rid of the left: -300px; offset for the <p> elements and add a clear: both; to the fieldset element. I tested it in IE and FF and it seemed to work just fine.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!