how to make editable span in fire fox

2019-05-06 14:27发布

问题:

even by setting contentEditable="true" in span tag , in fire fox this tag is not able to edit while there is no problem in IE. what can i do?

回答1:

contenteditable is a new html5 attribute, Chk if your browser supports it.

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>test</title>
    <script>
        if('contentEditable' in document.createElement('span')){
            alert('ContentEditable is supported by your browser');
        }else{
            alert('ContentEditable is not supported by your browser');
        }               
    </script>
</head>
<body>
    <h2> To-Do List </h2>
     <ul contenteditable="true">
        <li> <span>Break mechanical cab driver. </span></li>
        <li> <span>Drive to abandoned factory</span></li>
        <li><span> Visit Dentist</span> </li>
     </ul>
</body>
</html>

Incase you searching for a fix then,here is a plugin called contentEditable jQuery Plugin. url: http://valums.com/edit-in-place/



回答2:

That's because the contentEditable is not valid HTML, even if it is recognized by IE.

contentEditable attribute is valid HTML5 attribute and Firefox handle it pretty well from what I see.



回答3:

First off, and I may be mistaken here, but the correct usage from what I've seen across the web is lowercase and not camelcase.

<span contenteditable="true">EDIT THIS!</span>

Works in Firefox>MacOSX just fine, even without setting doctype.

The only explanation I can think of is that your Firefox version is outdated and you need to upgrade.



回答4:

it worked but when the span tag is in li tag it wont work!!

  • EDIT THIS!

this tag never is able to be edited