The mobile pit is implemented in an editable div placeholder

Source: Internet
Author: User

1. When we have a div set contenteditable = "true" This block element can be edited, if you want to implement placeholder direct write up is not effective

<div contenteditable= "true"  placeholder= "please write infomation" ></div>//no effect

2. You can add styles to implement

*[contenteditable= "true"]:empty:before{        content:attr (placeholder);        Color: #A9A9A9;    }

This code matches the attribute contenteditable= "true" when the element class capacity is empty when added: before pseudo element

attr (Placeholder) Gets the value of the property placeholder assigned to the content so that you can emulate the placeholder property in the Implementation text box,

3. When the first display in the Ipone machine is OK, when you enter the content and then empty the discovery does not show the contents of the placeholder, this is because this editable block is not empty at this time, there are newline characters,

If we have to use jquery,zepto and so on we can get the text () of this element, and then assign the value "" with this element;

If we use JS, innertext to get the value of the block element, you will find that whether your value is empty is true, there is no way to determine when I am empty (only in Ipone),

And then I went to see how the text () in jquery is implemented, using a Textcontent property that can be used to determine

The mobile pit is implemented in an editable div placeholder

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.