使用jquery替换一个图像按钮的提交按钮 [英] Replacing a submit button with a image button using jquery

查看:46
本文介绍了使用jquery替换一个图像按钮的提交按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我需要使用jquery的原因是因为我使用的是插件生成联系表单和jquery似乎是最有效的方式来取代它,而不会进入插件的代码。

在jQuery中执行它,并且您的表单是动态生成的,您可以应用这些

  var submit = $('form') .find( '输入[类型=提交]'); 
submit.hide();
submit.after('< input type = image src = test.jpg />');

因为我们无法在type = submit输入中放置图像我隐藏它并放置一个输入类型=我们也可以使用由DHuntrods提供的css通过

  var submit = $('form')。find('input [type = submit]'); 
submit.addClass('form-submit');


how could I go about replacing a form submit button with a image submit button using jquery?

The reason I need to use jquery is because I am using a plugin to generate the contact form and jquery seems like the most effective way of replacing it without going into the plugin's code.

解决方案

if you are doing it in jQuery, and your form is generated dynamically, you can apply these

var submit = $('form').find('input[type=submit]');
submit.hide();
submit.after('<input type=image src=test.jpg />');

since we cannot put an image in a type=submit input I hide it and place an input type=image since it also acts as a submit.

we can also use the css provided by DHuntrods by

var submit = $('form').find('input[type=submit]');
submit.addClass('form-submit');

这篇关于使用jquery替换一个图像按钮的提交按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆