Get Content and Attributes

Posted on Updated on

Get Content and Attributes

Three easy, nevertheless useful, jQuery options for DOM adjustment are:

• text ( ) — Models or maybe profits the text articles connected with picked aspects

• html ( ) — Models or maybe profits the information connected with picked aspects ( including HTML markup )

• val ( ) — Models or maybe profits the significance connected with variety job areas

These instance proves how to get proud of the jQuery text ( ) along with html ( ) methods:

< !DOCTYPE html >

< html >

< head >

< script src= “ https: / / ajax . googleapis . com / ajax / libs / jquery / 1 . 12 . 0 / jquery . min . js “ > < / script>

< script >

$ ( document ) . ready ( function ( ) {

$ ( “ #btnn “ ) . click ( function ( ) {

alert ( “ Text: “ + $ ( “ #test “ ) . text ( ) ) ;

} ) ;

$ ( “ #btne “ ) . click ( function ( ) {

alert ( “ HTML: “ + $ ( “ #test “ ) . html ( ) ) ;

} ) ;

} ) ;

< / script >

< / head >

< body >

< p id= “ test “ > This is some < b > bold < / b > text in a paragraph . < / p >

< button id= “ btnn “ > Show Text < / button >

< button id= “ btne “ > Show HTML < / button >

< / body >

< / html >

These instance proves how to get the significance associated with an enter subject with the jQuery val ( ) process:

< !DOCTYPE html >

< html >

< head >

< script src= “ https: / / ajax . googleapis . com / ajax / libs / jquery / 1 . 12 . 0 / jquery . min . js “ > < / script>

< script >

$ ( document ) . ready ( function ( ) {

$ ( “ button “ ) . click ( function ( ) {

alert ( “ Value: “ + $ ( “ #test “ ) . val ( ) ) ;

} ) ;

} ) ;

< / script >

< / head >

< body >

< p > Name: < input type= “ text “ id= “ test “ value= “ Mickey Mouse “ > < / p >

< button > Show Value < / button >

< / body >

< / html >

Get Features — attr ( )

The jQuery attr ( ) process is employed for getting characteristic ideals .

< !DOCTYPE html >

< html >

< head >

< script src= “ https: / / ajax . googleapis . com / ajax / libs / jquery / 1 . 12 . 0 / jquery . min . js “ > < / script>

< script >

$ ( document ) . ready ( function ( ) {

$ ( “ button “ ) . click ( function ( ) {

alert ( $ ( “ #aa “ ) . attr ( “ href “ ) ) ;

} ) ;

} ) ;

< / script >

< / head >

< body >

< p > < a href= “ http: / / www . cometolearn . esy . es “ id= “ aa “ > cometolearn . esy . es < / a > < / p >

< button > Show href Value < / button >

< / body >

< / html >

These instance proves how to get the significance from the href characteristic inside a link.

For more details and queries please feel free to email, visit or call us. Wishing you the very best for all your future endeavors.

Helpline: 9814666333, 8699444666

Email:info@technocampus.co.in

**************************************************************************************************************

Please fill the FORM and we shall contact you soon.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s