Register and join over 40,000 other developers!
Recent Topics
-
The Game You Are Waiting For?
WendellHarper - Dec 06 2020 01:21 PM
-
Quora and Reddit Backlinks
WendellHarper - Dec 06 2020 01:14 PM
-
Delete account
pindo - Jul 23 2020 01:33 AM
-
Print specific values from dictionary with a specific key name
Siten0308 - Jun 20 2019 01:43 PM
-
Learn algorithms and programming concepts
johnnylo - Apr 23 2019 07:49 AM
Recent Blog Entries
Recent Status Updates
Popular Tags
- networking
- Managed C++
- stream
- console
- database
- authentication
- Visual Basic 4 / 5 / 6
- session
- Connection
- asp.net
- import
- syntax
- hardware
- html5
- array
- mysql
- java
- php
- c++
- string
- C#
- html
- loop
- timer
- jquery
- ajax
- javascript
- programming
- android
- css
- assembly
- c
- form
- vb.net
- xml
- linked list
- login
- encryption
- pseudocode
- calculator
- sql
- python
- setup
- help
- game
- combobox
- binary
- hello world
- grid
- innerHTML

1 reply to this topic
#1
Posted 21 December 2011 - 09:13 PM
Hi im newbies in jquery, i want to use checkbox to create a font styling effect.
i have a div that shows the input text.
the checkbox indicates bold, italic and underline.
how do i do that?
can you show it also using radio button?
thank you.
i have a div that shows the input text.
the checkbox indicates bold, italic and underline.
how do i do that?
can you show it also using radio button?
thank you.
#2
Posted 21 December 2011 - 10:40 PM
You'll need to use the Element.checked property.
If the checkbox is checked, the Element.checked property will be 'true' , otherwise it would be 'false' .
Take a look at the following:
Or you could programmatically change the state of the checkbox, such as this:
As for the styling, you can use the style object. So if you have an HTML element like this:
Also, Element.style.textDecoration is for underlining, while Element.style.fontStyle is for italicizing.
Here's more reference to the style object:
HTML DOM Style object
<input type="checkbox" id="chk1" /> This is a checkbox...
If the checkbox is checked, the Element.checked property will be 'true' , otherwise it would be 'false' .
Take a look at the following:
if ($("#chk1").checked == true) alert ("The checkbox is checked."); else alert ("The checkbox is not checked.");
Or you could programmatically change the state of the checkbox, such as this:
$("#chk1").checked= true;, or also uncheck the checkbox:
$("#chk1").checked= false;
As for the styling, you can use the style object. So if you have an HTML element like this:
<div id="txt">Some text...</div>, you can programmatically change the style using the style object:
$("#txt").style.color= "#FF0000"; $("#txt").style.fontFamily= "Times New Roman"; $("#txt").style.fontSize= 12; $("#txt").style.fontWeight= "bold"; // This is from what I can recall.
Also, Element.style.textDecoration is for underlining, while Element.style.fontStyle is for italicizing.
Here's more reference to the style object:
HTML DOM Style object
Also tagged with one or more of these keywords: jQuery, jquery
Language Forums →
HTML, CSS and Javascript →
Jquery .hasClass not returning true for a classnameStarted by Wackostylee, 13 Oct 2018 ![]() |
|
![]() |
||
Language Forums →
HTML, CSS and Javascript →
Syntax and Reference Error?Started by Tonyobyo, 10 Jun 2016 ![]() |
|
![]() |
||
Language Forums →
HTML, CSS and Javascript →
JQuery/NodeJS AJAX Response HelpStarted by Poe, 27 Jan 2016 ![]() |
|
![]() |
||
Language Forums →
HTML, CSS and Javascript →
insert records using jquery and php not workingStarted by mutago, 12 Jul 2015 ![]() |
|
![]() |
||
![]() Call to script via ajax $.post fails unless followed by alert()Started by sayitblue, 11 Jul 2015 ![]() |
|
![]() |
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download