开发者

Changing font in jEditable control only when placeholder text is displayed

开发者 https://www.devze.com 2023-04-13 07:08 出处:网络
I have a div that I\'m turning into a jEditable control with code like this: $(\".ed-fld\").editable(\"/url\",

I have a div that I'm turning into a jEditable control with code like this:

         $(".ed-fld").editable("/url",
            {
              placeholder: "(Edit)", 
              tooltip: "Click to edit", 
              开发者_C百科indicator: "Saving. . ."
            } 
         );

It works fine.

Now, I would like to add an effect such that when the control is displaying the placeholder text it displays in a grey color. When the control contains actual text, it should obey the regular styling.

Is this possible through jEditable?


The placeholder string is directly assigned to the element's innerHTML, so you can include HTML tags in it with a class, e.g.

$('.ed-fld').editable('/url', {
    ...
    placeholder: '<span class="placeholder">(Edit)</span>'
});

Then you can style the placeholder class, e.g.

.placeholder { color: gray }

See it in action: http://jsfiddle.net/william/6VUHh/40/.

0

精彩评论

暂无评论...
验证码 换一张
取 消