click, , - . , -, , , , DOM . , .
, , javascript . , jquery . jquery -.
jquery trigger - - :
jQuery 1.3, trigger() ed DOM
, vba, : ie.document.foo.Click - . , jquery trigger script IE.
<a> (), , os_opt_dd. 13 ( ), . , (, <div>), .
, jquery, :
var anchor = $('a.os_opt_dd')[12];
$(anchor).trigger('mousedown');
:
$($('a.os_opt_dd')[12]).trigger('mousedown')
, mousedown, click. , (IMO) , . . Google/search Stack Overflow, / //jQuery .., . jquery, , , - ;)
, , excel-vba :
Option Explicit
Sub TestWithEarlyBinding()
Dim strUrl As String
Dim strJquery As String
Dim objBrowser As InternetExplorer
Dim objDocument As HTMLDocument
On Error GoTo CleanUp
'url and jquery required for automation
strUrl = "http://www.omahasteaks.com/product/Bacon-Wrapped-Filet-Mignons-4-5-oz-01144?ITMSUF=WZB"
strJquery = "$($('a.os_opt_dd')[12]).trigger('mousedown')"
'create IE
Set objBrowser = New InternetExplorer
'browse to page and wait for load
objBrowser.Visible = True
objBrowser.navigate strUrl
While objBrowser.readyState <> READYSTATE_COMPLETE 'READYSTATE_COMPLETE =4
DoEvents
Wend
'force jquery event on document
Set objDocument = objBrowser.document
objDocument.parentWindow.execScript strJquery, "JavaScript"
CleanUp:
If Err.Number <> 0 Then
Debug.Print Err.Number & ": " & Err.Description
End If
'objBrowser.Quit
Set objDocument = Nothing
Set objBrowser = Nothing
End Sub
. , . :
- Microsoft HTML
- Microsoft Internet Controls
Update
jquery trigger , 13- , :
$('#right_sku_form').find('div#selector-PAR-00000009957').find('a.os_opt_dd').trigger('mousedown')
find() DOM.
<form> id right_sku_form<div> id of selector-PAR-00000009957<div> , class of a.os_opt_dd
jquery strJquery vba .