按下按钮以“粗体” &安培;再次按下“Unbold” [英] Press button to "Bold" & press again to "Unbold"

查看:220
本文介绍了按下按钮以“粗体” &安培;再次按下“Unbold”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是JavaScript新手。我想用javascript制作一个按钮。当用户尝试按下按钮
时,特定的< #id>将变为粗体,然后再次按取消打磨。



我该怎么做?请参阅任何帮助材料。
Thanks!

解决方案

由于学习经验至关重要,特别是对于Javascript,我会在右边指导您方向。



首先,您应该查看事件绑定鼠标事件处理 jQuery的。你可以用这些知识做一些强大的事情,包括你想做什么。

第二,看看基本的jQuery 选择器。学习简单的基于CSS的选择器并不难,您可以使用这些选择器来选择所需的 id



第三,查看jQuery的 css() 功能,它属于jQuery的 CSS 类别。您可以使用它来设置元素的不同属性,包括字体重量。


I am new to javascript. I want to make a button in html using javascript. When user try to press the button the specific <#id> is going to be "Bold" and press again to "Unbold".

How can I do this ? please refer any helping material. Thanks !

解决方案

Since the learning experience is vital, especially for Javascript, I'll guide you in the right direction.

First, you should look into event binding and mouse event handling with jQuery. You can do some powerful stuff with this knowledge, including what you would like to do.

Second, look into basic jQuery selectors. It's not hard to learn the simple CSS-based selectors that you can use to select your desired id.

Third, look at the css() function of jQuery, which falls under jQuery's CSS category. You can use this to set different properties of elements, including font weight.

这篇关于按下按钮以“粗体” &安培;再次按下“Unbold”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆