Skip to main content

[jQuery]: Get and Set value in html element

1. Get value from html input element

$(document).ready(function() {
var test= $('#test_id').val();//get value from input with id #test_id
        alert('test: ' + test);
});

2. Get value from html label element

$(document).ready(function() {
var test= $('#test_id').text();//get value from label with id #test_id
        alert('test: ' + test);
});

3. Set value into html hidden element

$(document).ready(function() {
var test= $('#test_id').text();//get value from id #test_id
        alert('test: ' + test);
        $('#hidden_field').val(test);//set value test into id #hidden_field
});

Comments

Popular posts from this blog

It's a new experience for me

Okay, i think i'm kind of coward type, whenever there is some special occasion or some important tasks or duty being assigned to me, i will worry first, i know in another word, it's lack of confident.

For this time, I will be traveling to US on this coming September - of course - it's a business trip , and i will need to apply for US Visa and go for a Visa interview.

So, i completed the application on 7th July 2017 and the earliest Visa interview schedule will be on 25th July 2017.

During the Visa interview scheduling, i still don't feel the heat yet, i started to worry 4 days before the actual interview day.

Starts to imagine all the worst cases that might be happened before/during the interview, and even dream of it- a nightmare that i went to US Embassy without all my documents. **no doubt, i have a stack of documents prepared, from the business invitation letter, itinerary, identification card photocopy, blah blah blah.....and a super ugly 2 * 2 inches photo of min…

Skytrex Adventure-"Extreme Challenge"

Someone said that i will for sure upload the photo and show off with my strength... As i was incredibly,unexpectedly, unbelievably finished the 24 challenges of skytrex adventure... Uhoo... I so called that challenge as "One day Tarzan" challenges... As every challenges are on the platform at trees... The highest is 22 meters... I have conquered it... 12th June...is the day... around 1pm...SZ,SW and TJ reached in my place... We take about 1 hour to reach the location... The sky was greyness...Finally, it was raining... As we reached in the destination...the rain stopped... We take the so called bus to reach at the Skytrex in the TPM... We went to the pondok to register ourselves...and signed a paper... i don't really read the content...is something about any accident happen, it's on your own risk...and we required to fill in the people to contact if accident happen... We rent a locker to keep our stuffs (RM 5), bought a pair of gloves (RM3 per pair)... right after that we equipped w…

曾经太年轻

在所有的所有以后。。。发现人心是险恶的。。。
曾经以为简单就只是复杂的反义词。。。
想了又想。。。应该超乎反义词。。。好远好远。。。
选择去或留。。。根本是谎言。。。因为你没有权利选择。。。
真的就只有习惯和慢慢的熟悉看穿。。。

珍惜您的所有。。。

*不要问我为什么,因为我自己也不知道*

就想安安静静的过。。。