English 中文(简体)
风格文本与使用 Java本的任何其他内容一样。
原标题:Style textarea content with the same style as any other element using JavaScript?

I would like to dynamically insert textareas into different parts of my site and have the styling of the text in the textarea match the style of the normal text in that element. Is it possible to do this with JavaScript? I thought that perhaps I could loop through all the obj.style properties and just apply them to the textarea.

例如,在 st流体上使用的字体是10px(?) 最终内容案文与14px Arial一样。

问题回答

这样做的最佳途径是通过一个中央支助事务组。 Either change the Format of all textareas with textarea{* CSS */ } or use a special section for them such as textarea.dynamically Inserted{* CSS */} with <textarea category=“dynamically Inserted”></aretexta>

采用分类法,你可以列举你们想要的众多财产,并将这些财产列入你补充的内容:

function addTextArea(targetId) {
    $( #  + targetId).add( textarea )
        .css( font-family , $( #  + targetId).css( font-family ))
        .css( font-size , $( #  + targetId).css( font-size )); //etc...
}




相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签