iyop45 iyop45 - 2 months ago 8
HTML Question

How do I make plain text act as a button on click?

I was wondering what is the simplest way of making just plain text act as a button (with minimal html). Text:

<li class="indiv-nav" ><a target="_blank" href="/">About</a></li>


I need the text about to perform that of:

<div id="button"><input type="submit" value="Press me please!" /></div>


Sorry if this is a "stupid" question but, I'm still learning and I find it crazy how theres no "simpler" solution than those I found from googling.

Answer

try

<a href="javascript: void(0)" id="button">Submit</a>

jQuery

$(function(){
    $("#button").bind("click",function(){
        $("#idOfYourForm").submit();  // consider idOfYourForm `id` of your form which you are going to submit
    });
});

JavaScript

document.getElementById("button").onclick = function(){
    document.getElementById("idOfYourForm").submit();
};