why href links are not added to html using jquery


xiaqian1999

I create variables for event links and when the user enters the link I want it to be displayed as a hyperlink in HTML using jquery. Since the user can enter an infinite number of times, the output of the link will be on the next line.

var $event_link_selector = $('#event-link');
var event_link = $event_link_selector.val();
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<label for="event-link">Event Link:</label>
<textarea id="event-link"></textarea>

For example: if the user enters www.example.com in the test area , I want the page to return me that link and be able to click it. These are the jQuery I'm currently trying but not working

//returns me the user input link as string instead of link
"<br> <a class='event-description'>"+ event.event_link + "</a>"

//returns none
"<br> <a class='event-description' href='" + event.event_link + "'></a>"

Biller

You didn't share your entire jQuery code... but it's already clear that your quotes are in the wrong place!

$('#event-link').on('focusout',function(){
  var event_link=$(this).val();
  $(this).parent('.link-container').append('<a class="event-description" href="' + event_link + '">'+event_link+'</a>');
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="link-container">
<label for="event-link">Event Link:</label>
<textarea id="event-link"></textarea>
</div>

Related


why href links are not added to html using jquery

xiaqian1999 I create variable for event link and when user enter link I want it to be displayed as hyperlink in HTML using jquery. Since the user can enter an infinite number of times, the output of the link will be on the next line. var $event_link_selector =

why href links are not added to html using jquery

xiaqian1999 I create variable for event link and when user enter link I want it to be displayed as hyperlink in HTML using jquery. Since the user can enter an infinite number of times, the output of the link will be on the next line. var $event_link_selector =

why href links are not added to html using jquery

xiaqian1999 I create variables for event links and when the user enters the link I want it to be displayed as a hyperlink in HTML using jquery. Since the user can enter an infinite number of times, the output of the link will be on the next line. var $event_li

why href links are not added to html using jquery

xiaqian1999 I create variable for event link and when user enter link I want it to be displayed as hyperlink in HTML using jquery. Since the user can enter an infinite number of times, the output of the link will be on the next line. var $event_link_selector =

why href links are not added to html using jquery

xiaqian1999 I create variable for event link and when user enter link I want it to be displayed as hyperlink in HTML using jquery. Since the user can enter an infinite number of times, the output of the link will be on the next line. var $event_link_selector =

why href links are not added to html using jquery

xiaqian1999 I create variable for event link and when user enter link I want it to be displayed as hyperlink in HTML using jquery. Since the user can enter an infinite number of times, the output of the link will be on the next line. var $event_link_selector =

Remove all href links using jQuery

Aston I am trying to remove all links from the parsed site, then remove the div and place it in the main code. The problem is that I'm trying to remove all "href" links in the extracted div, but can't get anywhere. I've tried using "CSS" but it only works in C

How to replace href links in text using jQuery

Alpha reticulum cells HTML example: <p><a href='link1' target='_blank'><font color='blue' size='4'>TEXT 1</font></a></p> <br /> <p><a href='link2' target='_blank'><font color='blue' size='4'>TEXT 2</font></a></p> <br /> <p><a href='link3' target='_

How to replace href links in text using jQuery

Alpha reticulum cells HTML example: <p><a href='link1' target='_blank'><font color='blue' size='4'>TEXT 1</font></a></p> <br /> <p><a href='link2' target='_blank'><font color='blue' size='4'>TEXT 2</font></a></p> <br /> <p><a href='link3' target='_

jQuery added href

Ringtone 4407 I'm trying to use jQuery to sitelink but it's not working. Here is my code. $(document).ready(function() { $( ".class" ).append( "<p><a href="http://www.google.com">Google</a></p>" ); }); j08691 Fix your quote: $(document).ready(function() {

jQuery added href

Ringtone 4407 I'm trying to use jQuery to sitelink but it's not working. Here is my code. $(document).ready(function() { $( ".class" ).append( "<p><a href="http://www.google.com">Google</a></p>" ); }); j08691 Fix your quote: $(document).ready(function() {

Extract HTML links with href

Crappie 101 I used the following code: $URI = $webpage $HTML = Invoke-WebRequest -Uri $URI $price = ($HTML.ParsedHtml.getElementsByTagName("div") | Where { $_.className -eq 'price' }).innerText Extract information from the following HTM

Can HTML style links be added to SWT StyledText?

hi I know that SWT has a Link class that can create HTML a href styled links as widgets, but I'm not trying to find a way to make some text in a StyledText control appear and act as a link. I have a feeling Eclipse does this in its code editor if you hold down

Prolog HTTP dynamically added links to html

Hasher I'm new to prolog and declarative programming and I'm having a hard time achieving the following. I'm following this tutorial and now want to display many links on the page. Which links to show depends on some facts/variables. Here is my current code: l

Can HTML style links be added to SWT StyledText?

hi I know that SWT has a Link class that can create HTML a href styled links as widgets, but I'm not trying to find a way to make some text in a StyledText control appear and act as a link. I have a feeling Eclipse does this in its code editor if you hold down

Prolog HTTP dynamically added links to html

Hasher I'm new to prolog and declarative programming and I'm having a hard time achieving the following. I'm following this tutorial and now want to display many links on the page. Which links to show depends on some facts/variables. Here is my current code: l

Can HTML style links be added to SWT StyledText?

hi I know that SWT has a Link class that can create HTML a href styled links as widgets, but I'm not trying to find a way to make some text in a StyledText control appear and act as a link. I have a feeling Eclipse does this in its code editor if you hold down

Prolog HTTP dynamically added links to html

Hasher I'm new to prolog and declarative programming and I'm having a hard time achieving the following. I'm following this tutorial and now want to display many links on the page. Which links to show depends on some facts/variables. Here is my current code: l

Prolog HTTP dynamically added links to html

Hasher I'm new to prolog and declarative programming and I'm having a hard time achieving the following. I'm following this tutorial and now want to display many links on the page. Which links to show depends on some facts/variables. Here is my current code: l

Remove HTML links with jQuery

username I have a jQuery string: <p> <h1>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod</h1> tempor invidunt ut labore et <a target="_blank" class="marked user-link" href="/user/fc07254b-c063-47e1-a434-0da87b62d105">

Remove HTML links with jQuery

username I have a jQuery string: <p> <h1>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod</h1> tempor invidunt ut labore et <a target="_blank" class="marked user-link" href="/user/fc07254b-c063-47e1-a434-0da87b62d105">

Remove HTML links with jQuery

username I have a jQuery string: <p> <h1>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod</h1> tempor invidunt ut labore et <a target="_blank" class="marked user-link" href="/user/fc07254b-c063-47e1-a434-0da87b62d105">