How to change anchor tag's text on click using jquery?


Start

I want to change the text of anchor tag on click event using jquery.

Anchor Tag:

 <a id="view_email" href="#"><i class="fa fa-envelope"></i> View Email</a>

query code:

<script type="text/javascript">
$(document).ready(function(){
    $("#view_email").click(function(){
        $(this).text() = "[email protected]";
    });
});
</script>
Neji Rox

$(document).ready(function(){
    $("#view_email").click(function(){
        $(this).text("[email protected]");//you will loose <i> tag
        //$(this).html("<i class="fa fa-envelope"></i> View Email")//better to use html instead of text.
    });
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<a id="view_email" href="javascript:void(0);"><i class="fa fa-envelope"></i> View Email</a>

Related


Change anchor tag's text on click in ng-click method

username I have an anchor tag that when clicked should change its text in the ng-click function. Can someone please help me? Here is the code: <div ng-app="Test"> <div ng-controller="Foo"> <a class="anchClass" ng-click="hi($event)">click me</a> </div> an

Change anchor tag's text on click in ng-click method

username I have an anchor tag that when clicked should change its text in the ng-click function. Can someone please help me? Here is the code: <div ng-app="Test"> <div ng-controller="Foo"> <a class="anchClass" ng-click="hi($event)">click me</a> </div> an

How to change anchor tag text on click in angular 2

Prakash I have to toggle text On view and Hide how can I do this? I tried a lot but it didn't work. I don't want to use Jquery for this. I just want to use angular. Can anyone help me with this? ? <a class="history-link view-history-class" id="show-view-addre

Change anchor tag text when using PhoneGap and jQuery

Jeff Clark As a preamble, I'm using PhoneGap. When I click on the category title, I have fetched that title and set it in sessionStorage. Now I want to set the "back" button of the new PhoneGap page (showing some information contained in the category) to the c

Change anchor tag text when using PhoneGap and jQuery

Jeff Clark As a preamble, I'm using PhoneGap. When I click on the category title, I have fetched that title and set it in sessionStorage. Now I want to set the "back" button of the new PhoneGap page (showing some information contained in the category) to the c

Disable or change anchor tag's href using jQuery

Fani I have HTML like this: <div id="StoreLocatorPlaceHoler_ctl07_ctl00_ctl00_pager_ctl00_ctl00_numeric" class="sf_pagerNumeric"> <a href="http://www.domain.com/store-list">1</a> <a href="http://www.domain.com/store-list/page/2">2</a> <a href="http

Disable or change anchor tag's href using jQuery

Fani I have HTML like this: <div id="StoreLocatorPlaceHoler_ctl07_ctl00_ctl00_pager_ctl00_ctl00_numeric" class="sf_pagerNumeric"> <a href="http://www.domain.com/store-list">1</a> <a href="http://www.domain.com/store-list/page/2">2</a> <a href="http

Click on anchor tag with text

Tania How to click on anchor tag with specific text? For example, I have the following anchors in my page <a>one</a> <a>two</a> <a>three</a> Now, the user enters one. How to click a label with text as one? I tried this: var uservar='one'; $('a [text=$uservar]

Click on anchor tag with text

Tania How to click on anchor tag with specific text? For example, I have the following anchors in my page <a>one</a> <a>two</a> <a>three</a> Now, the user enters one. How to click a label with text as one? I tried this: var uservar='one'; $('a [text=$uservar]

Change anchor text after click with jQuery

caustic I am using the following code to show/hide a div when an anchor is clicked. $(document).ready(function(){ $(".slidingDiv").hide(); $(".show_hide").show(); $('.show_hide').click(function(){ $(".slidingDiv").slideToggle(); });

Change anchor text after click with jQuery

caustic I am using the following code to show/hide a div when an anchor is clicked. $(document).ready(function(){ $(".slidingDiv").hide(); $(".show_hide").show(); $('.show_hide').click(function(){ $(".slidingDiv").slideToggle(); });

How to click anchor tag from javascript or jquery

151291 There is an anchor tag, try to click it from javascript, it doesn't respond, and when the page loads, it goes to next.phpwithout manually clicking the anchor tag . How to archive it? <!DOCTYPE html> <html> <head> <title></title> <script src="jqu

How to click anchor tag from javascript or jquery

151291 There is an anchor tag, try to click it from javascript, it doesn't respond, and when the page loads, it goes to next.phpwithout manually clicking the anchor tag . How to archive it? <!DOCTYPE html> <html> <head> <title></title> <script src="jqu

How to click anchor tag from javascript or jquery

151291 There is an anchor tag, try to click it from javascript, it doesn't respond, and when the page loads, it goes to next.phpwithout manually clicking the anchor tag . How to archive it? <!DOCTYPE html> <html> <head> <title></title> <script src="jqu

How to click anchor tag from javascript or jquery

151291 There is an anchor tag, try to click it from javascript, it doesn't respond, and when the page loads, it goes to next.phpwithout manually clicking the anchor tag . How to archive it? <!DOCTYPE html> <html> <head> <title></title> <script src="jqu

How to click anchor tag using Selenium WebDriver

Shubham Mishra: I can't click the button with some visibility issues. I need to hover over the link before clicking the same link. <a tabindex="0" class="cardPreviewLink expand-icon" aria-label="card opens in new tab" target="_blank" id="card-p

How to click anchor tag using Selenium WebDriver

Shubham Mishra: I can't click the button with some visibility issues. I need to hover over the link before clicking the same link. <a tabindex="0" class="cardPreviewLink expand-icon" aria-label="card opens in new tab" target="_blank" id="card-p

How to click anchor tag using Selenium WebDriver

Shubham Mishra: I can't click the button with some visibility issues. I need to hover over the link before clicking the same link. <a tabindex="0" class="cardPreviewLink expand-icon" aria-label="card opens in new tab" target="_blank" id="card-p

How to click anchor tag using Selenium WebDriver

Shubham Mishra: I can't click the button with some visibility issues. I need to hover over the link before clicking the same link. <a tabindex="0" class="cardPreviewLink expand-icon" aria-label="card opens in new tab" target="_blank" id="card-p

How to click anchor tag using Selenium WebDriver

Shubham Mishra: I can't click the button with some visibility issues. I need to hover over the link before clicking the same link. <a tabindex="0" class="cardPreviewLink expand-icon" aria-label="card opens in new tab" target="_blank" id="card-p

How to click anchor tag using Selenium WebDriver

Shubham Mishra: I can't click the button with some visibility issues. I need to hover over the link before clicking the same link. <a tabindex="0" class="cardPreviewLink expand-icon" aria-label="card opens in new tab" target="_blank" id="card-p

How to change link text on click using jQuery?

bird Here is my codepen to see where I am. I want to change "read more" to "read less" when the div expands, then back to "read more" when it closes, etc. I thought maybe check if .expand-btn has class .view and then do a conditional to change the innerHTML bu

How to convert <text> (text tag) to anchor tag in jQuery?

Archie I have a <text>label that contains plain text, but I want to display a hyperlink instead of plain text. <svg width="800" height="600" class="overlay"> <g transform="translate(100,220)"> <path class="link" d="M80,120C120,120 120,106.66666666666666

How to convert <text> (text tag) to anchor tag in jQuery?

Archie I have a <text>label that contains plain text, but I want to display a hyperlink instead of plain text. <svg width="800" height="600" class="overlay"> <g transform="translate(100,220)"> <path class="link" d="M80,120C120,120 120,106.66666666666666

How to convert <text> (text tag) to anchor tag in jQuery?

Archie I have a <text>label that contains plain text, but I want to display a hyperlink instead of plain text. <svg width="800" height="600" class="overlay"> <g transform="translate(100,220)"> <path class="link" d="M80,120C120,120 120,106.66666666666666