user2791952
user2791952

Reputation: 67

input target value with jquery

Hi I've tried a few different ways of doing this but nothings working for me, I'm using a system that I cannot physically edit the code I need. I have an input with the following code

<input type="submit" name="ctl10$loginImageButton" value="Logout" id="ctl10_loginImageButton"     class="cssloginImageButtonlogout cssbutton">

And all I need to do is change the value of the value from "Logout" to "GO" using jQuery

If someone could help i'd appreciate it I'm starting to pull my hair out now :/ Thanks

Upvotes: 5

Views: 7542

Answers (3)

Code Lღver
Code Lღver

Reputation: 15603

Use this jQuery:

$(document).ready(function(){
    $("input[type=submit]").val("Go");
});

OR can use this:

$(document).ready(function(){
    $("#ctl10_loginImageButton").val("Go");
});

Make sure that you are including the JS at right place. means it should be only for this page. If you want to change the Text only this button.

Upvotes: 3

Suraj Singh
Suraj Singh

Reputation: 4059

$('#ctl10_loginImageButton').val('GO');

OR

$('input[value=Logout]').val('GO');

Upvotes: 1

James Hibbard
James Hibbard

Reputation: 17735

This should do the trick for you:

$("input[value='Logout']").val("GO");

jQuery makes it easy to select any element by attribute and alter it accordingly. http://api.jquery.com/attribute-equals-selector/

Upvotes: 4

Related Questions