简体   繁体   English

动态加粗选中的文本

[英]Bold selected Text dynamically

I want Bold a part of my string dynamically . 我要动态地将字符串的一部分加粗。 when my user select part a text in ASP.Net and click Bold button than his text going to Bold . 当我的用户在ASP.Net中选择零件文本并单击粗体按钮时,他的文本将变为粗体。 what am i going to do ? 我该怎么办? Thanks in Advance . 提前致谢 。

Instead of id_123 in someFunc use the id of the DOM object that you want the onclick registered with. 代替someFunc中的id_123,使用要向其注册onclick的DOM对象的ID。

<html>
<body>
    <p id="id_123" onClick="someFunc()">Here is some bolded text </p>
    <script type="text/javascript">
    function someFunc() {
        var value = document.getElementById('id_123');    
        value.setAttribute('style', 'font-weight: bold;');
    }
    </script>
</body>
</html>

On button click add style to the text. 在按钮上单击添加样式到文本。

are you using javascript , or js libraries like jquery. 您在使用javascript还是jQuery之类的js库。

style=" font-weight:bold" 

http://www.eggheadcafe.com/community/aspnet/17/10144717/css-style-change-when-im-clicking-link-button.aspx http://www.eggheadcafe.com/community/aspnet/17/10144717/css-style-change-when-im-clicking-link-button.aspx

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 检查richtextbox上的选定文本是否全部为粗体 - Check if selected text on richtextbox is all bold or not 如何检查RichTextBox中选定的文本是否具有粗体样式 - How to check if the selected text in RichTextBox has bold style 我可以动态地使文本块中的文本部分变为粗体吗? - Can i dynamically make part of text in textblock bold? 获取所选动态文本框的文本c# - get text of a selected dynamically textbox c# 需要使用javascript将选定的文本设置为粗体/斜体/下划线,并使用c#保存和检​​索相同的文本 - Need to make selected text as bold/italic/underline using javascript, and also save & retrieve the same using c# 如何在 WPF 中的 Textbox/Richtextbox 中为所选文本制作粗体按钮? - How can i make a button for Bold a selected text in Textbox/Richtextbox in WPF? ListView中所选项目的粗体标签? - Bold label for selected item in ListView? 检查所选的dataGridView行是否为粗体 - Check if the selected dataGridView row is bold 如何在 Gtk# 中做粗体、斜体、下划线按钮,又名如何在 gtk 中动态格式化文本 - How to do Bold, Italic, Underline buttons in Gtk# aka How to dynamically format text in gtk 如何使用MVVM,C#和没有Code-Behind将Row的文本动态设置为粗体? - How to dynamically set the Row's text to bold, using MVVM, C# and no Code-Behind?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM