I am trying to create custom links based on different buttons using this html.
You have multiple div
elements with id="linkified"
.
id
is unique; you cannot have more than one control with the same id.
You could change your id
attributes to class
attributes and do something like this:
<input type="text" name="coachid" id="textbox1" value="22984" />
<br />
<br/>
<button class="txtLinky" id="Mickey">Click Link</button>
<br/>
<div class="linkified">value</div>
<br/>
<button class="txtLinky" id="Donald">Click Link</button>
<br/>
<div class="linkified">value</div>
$(".txtLinky").on("click", function ()
{
var $this = $(this),
id = $this.attr("id"),
text = $("#textbox1").val();
$this
.nextAll('.linkified:first')
.css({ padding: '10px' })
.html
(
'http://www.example.com/'
+ id
+ '?referringRepId='
+ text
)
.linkify
({
tagName: 'a',
target: '_blank',
newLine: '\n'
});
});