我有一个javascript文件,我想在点击div时启动。
单击div“option_one”时我已经这样了,输入将设置为“选项1”:
var restuls= [];
for (var i= 0; i < data.length; i++)
{
restuls += "<td>" + widget[i].name + "</td>" +
"<td>" + widget[i].age + "</td>" +
"<td>" + widget[i].status + "</td>" +
"<a href='widget.html?id=" + widget[i].id + "&age=" + widget[i].age + "&status=" + widget[i].status + "&name=" + widget[i].name.replace("'","%27") + "'</a><button>Edit</button> </td>"
}
$('#widget_table').empty().append(restuls);
单击div后如何触发另一个js文件?
我尝试使用getScript,但我无法使用它。
亲切的问候,
阿瑞
答案 0 :(得分:2)
无需在calculate.js
事件中加载click
文件。只需加载页面加载就像这样:
HTML:
<!--Your page HTML here... -->
<!--Before your closing body tag-->
<script type="text/javascript" src="somefile.js"></script>
<script type="text/javascript" src="calculate.js"></script>
JS:
// This is inside somefile.js
$("#option_one").click(function() {
$("#input").val('Option 1');
// This function is inside calculate.js
calculate();
});
答案 1 :(得分:0)
Option Explicit
Sub Test()
Debug.Print AllValuesIdentical(14, 14, 14, 14, 14, 14, 14, 14, 14) 'true
Debug.Print AllValuesIdentical(5, 5, 5, 5, 5, 3, 5, 5) 'false
Debug.Print AllValuesIdentical("go", "go", "go", "go") 'true
Debug.Print AllValuesIdentical("go", "go", "go", "GO") 'also true
Debug.Print AllValuesIdentical(283.14, 283.14, 283.14) 'true
End Sub
Function AllValuesIdentical(ParamArray vals() As Variant) As Boolean
Dim uniqueCheck As Collection
Dim val As Variant
Set uniqueCheck = New Collection
On Error Resume Next
For Each val In vals
uniqueCheck.Add val, CStr(val)
Next val
If uniqueCheck.Count = 1 Then
AllValuesIdentical = True
Else
AllValuesIdentical = False
End If
On Error GoTo 0
Set uniqueCheck = Nothing
End Function