问题描述
我是JavaScript新手。我想用javascript制作一个按钮。当用户尝试按下按钮
时,特定的< #id>将变为粗体,然后再次按取消打磨。
我该怎么做?请参阅任何帮助材料。
Thanks!
由于学习经验至关重要,特别是对于Javascript,我会在右边指导您方向。
首先,您应该查看和 jQuery的。你可以用这些知识做一些强大的事情,包括你想做什么。
第二,看看基本的jQuery 。学习简单的基于CSS的选择器并不难,您可以使用这些选择器来选择所需的 id
。 第三,查看jQuery的功能,它属于jQuery的类别。您可以使用它来设置元素的不同属性,包括字体重量。
I am new to javascript. I want to make a button in html using javascript. When user try to press the buttonthe 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”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!