I have this code where I insert a read more link after a label with a specific ID:
$( "<a class='readMore' href='/moreByggherre' id='moreByggherre'>Läs mer</a>" ).insertAfter( $("label[for='Byggherre']") );
The above code works, but since I will be doing this a lot I would like to have a function which just takes the ID and outputs the html code with inserAfter.
I tried this, but it doesn't seem to work:
createReadMoreBtn('Byggherre');
function createReadMoreBtn($id){
$insertTxt = "<a class='readMore' href='/more".$id."' id='more".$id."'>Läs mer</a>";
$( $insertTxt ).insertAfter( $("label[for='".$id."']") );
}
Could you try this;