我有以下代码,看起来我的第一个脚本与prototype.js冲突。每当我删除prototype.js时,第一个脚本的功能都可以正常工作。重新添加后,表单上的原型功能又回来了,但我的第一个脚本根本无法工作。我怎样才能做到这一点?
<script>
$(document).ready(function() {
$('a[name=modal]').click(function(e) {
e.preventDefault();
var id = $(this).attr('href');
var maskHeight = $(document).height();
var maskWidth = $(window).width();
$('#mask').css({'width':maskWidth,'height':maskHeight});
$('#mask').fadeIn(1000);
$('#mask').fadeTo("slow",0.8);
var winH = $(window).height();
var winW = $(window).width();
$(id).css('top', winH/2-$(id).height()/2);
$(id).css('left', winW/2-$(id).width()/2);
$(id).fadeIn(2000);
$("#textbox").focus();
});
$("#textbox").blur(function (e) {
e.preventDefault();
$('#mask').hide();
$('.window').hide();
}).keyup(function (e) {
if($(this).val().substr($(this).val().length-1)=="?") {
$('#mask').hide();
$('.window').hide();
setFromCCS($("#textbox").val());
}
});
$('.window .close').click(function (e) {
e.preventDefault();
$('#mask').hide();
$('.window').hide();
setFromCCS($("#textbox").val());
});
$('#mask').click(function () {
$(this).hide();
$('.window').hide();
});
});
function setFromCCS(ccs) {
var index1 = ccs.indexOf("%B") + 2;
var index2 = ccs.indexOf("^") + 1;
var index3 = ccs.indexOf("^", index2 + 1) + 1;
var cardNumber = ccs.substring( index1, index2 - 1);
var expMonth = ccs.substr(index3 +2, 2);
var expYear = ccs.substr(index3, 2);
var holderName = ccs.substring(index2, index3 - 1);
var monthNames = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
var d = new Date(expMonth+"-01-20"+expYear);
$("#input_6_cc_number").val(cardNumber);
$("#input_6_cc_exp_month").val(monthNames[d.getMonth()]);
$("#input_6_cc_exp_year").val("20"+expYear);
}
</script>
<!--[if lt IE 9]><script src="https://cdn.jotfor.ms/js/vendor/flashcanvas.js?3.3.17929" type="text/javascript"></script><![endif]-->
<script src="https://cdn.jotfor.ms/js/vendor/jquery-1.8.0.min.js?v=3.3.17929" type="text/javascript"></script>
<script src="https://cdn.jotfor.ms/js/vendor/jSignature.min.noconflict.js?3.3.17929" type="text/javascript"></script>
<script src="https://cdn.jotfor.ms/js/vendor/jotform.signaturepad.js?3.3.17929" type="text/javascript"></script>
<script src="https://cdn.jotfor.ms/static/jotform.forms.js?3.3.17929" type="text/javascript"></script>
<script src="https://cdn.jotfor.ms/static/prototype.forms.js"></script>
正在使用Jquery版本1.4.4 1.2.6和1.8.0
答案 0 :(得分:1)
如果我没记错的话,将脚本中的所有$更改为jQuery,所以:
$(document).ready(function() {
$('a[name=modal]').click(function(e) {
e.preventDefault();
var id = $(this).attr('href');
变为:
jQuery(document).ready(function() {
jQuery('a[name=modal]').click(function(e) {
e.preventDefault();
var id = jQuery(this).attr('href');
等等。
然后说:
<script type="text/javascript">
jQuery.noConflict();
</script>
直接位于<head>
答案 1 :(得分:0)
如果您将“$”作为参数,则可以使用“$”代替jQuery。
jQuery(document).ready(function($) {
$('a[name=modal]').click(function(e) {
e.preventDefault();
var id = $(this).attr('href');
答案 2 :(得分:0)
这只是一个Public Sub CheckIfCurrent_Published()
Const kFml As String = "=IF( ISERROR( MATCH( RC1, #rSrc, 0 ) ), ""No"", ""Yes"" )"
Dim rTrg As Range, rSrc As Range
Dim sFml As String
Rem Set Target Range (Sheet `ers`)
With ThisWorkbook.Worksheets("ers")
Set rTrg = .Range("N2:N" & .Cells(.Rows.Count, 1).End(xlUp).Row)
End With
Rem Set Target Range (Sheet `rsca`)
With ThisWorkbook.Worksheets("rsca")
Set rSrc = .Range("A1:A" & .Cells(.Rows.Count, 1).End(xlUp).Row)
End With
Rem Reset Formula
sFml = kFml
sFml = Replace(sFml, "#rSrc", rSrc.Address(ReferenceStyle:=xlR1C1, External:=1))
Rem Apply Formula
With rTrg
.FormulaR1C1 = sFml
.Value = .Value2
End With
End Sub
问题。
在Scope
上下文中移动您的函数setFromCCS
!
样品:
$(document).ready(function() {
另外,使用匿名函数创建一个新的作用域并添加如下的jQuery上下文:
$(document).ready(function() {
// Other Code
function setFromCCS(ccs) {
// Code...
}
});