Get the value or attributes of an element by name - jQuery

86
Views
1
Answers

I have a element like

input name="myname" value="hi"/>

How do I get its value in jQuery using its name?

edit | flag
William Patrick
Asked on: Jan 29, 2012 at 4:32AM

1 Answers

110
5
110

You can try something like this

var val=$('input[name=myname]') // matches exactly 'myname'

alert
(val); // will give a alert message "hi"

$
('input[name^=myname]') // matches those that begin with 'myname'
edit | flag
Askamoeba Member
Answered on: Jan 29, 2012 at 4:39AM

Post your Answer

Search

Welcome to Ask Amoeba!
This is 100% free and interactive site for sharing professional Questions and Answers, Opensource projects, Interview questions.
Learners, beginners, Experts stop and share your knowledge and ideas!

Browse Categories

Browse Tags