Can I submit a html Like this: with
?
For better semantics and graceful degradation, I suggest you do this:
$(document).ready(function(){
$('form input[type="submit"]').replaceWith('<div class="submit">Submit the form by clicking this</div>'); // replace submit button with div
$('.submit').live('click', function() {
$(this).closest('form').submit();
});
});
This way, your form remains usable for clients without JS.
That being said: Just style your input to look the way you want it to with CSS ;)
Only by using JavaScript, typically you'd use jQuery and tie the click event of the div to the submit event of the form.
See: http://api.jquery.com/submit/
The example there even demonstrates this exact scenario.
Bind the div click event.
$("div").click(function(){ $("form#myForm").submit(); });
why don't you just style a button to look like a regular div? :)
button{
border:none;
background:none;
padding:0;
text-align:left;
}
$('#myDiv').click(function() {
$('#myForm').submit();
});