简体   繁体   English

如何使用execScript将参数传递给jquery / javascript函数

[英]How to pass a parameter to a jquery/javascript function using execScript

I have the following code to select the first item in a kendoDropDownList. 我有以下代码来选择kendoDropDownList中的第一项。 By changing the parameter in select from a 1 to a 2, I can select the second item. 通过将select中的参数从1更改为2,我可以选择第二项。 Is there a way to pass a parameter, as in 1 or 2 or 3 etc. to this line ? 有没有一种方法可以将参数(例如1或2或3等)传递到此行?

ie.Document.parentWindow.execScript "$('#drgdTankCrude').data('kendoGrid').dataItem($('#Tank_ID').data('kendoDropDownList').select(1));"

I've tried the following by setting a variable called xp using double quotes, single quotes, no quotes, but nothing happens unless it's actually a number of valid items in the dropDownList. 我已经尝试通过使用双引号,单引号,无引号设置名为xp的变量来尝试以下操作,但是除非在dropDownList中实际上是许多有效项,否则什么也不会发生。

ie.Document.parentWindow.execScript "$('#drgdTankCrude').data('kendoGrid').dataItem($('#Tank_ID').data('kendoDropDownList').select(""xp""));"

Slai gave me the correct answer. 斯莱给了我正确答案。 The line is posted below. 该行发布在下面。

Setting the xp variable, it was passed correctly 设置xp变量,它已正确传递

ie.Document.parentWindow.execScript "$('#drgdTankCrude').data('kendoGrid').dataItem($('#Tank_ID').data('kendoDropDownList').select(" & xp & "));"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM