I'm pletely new to scripting and i'm having an awful time trying to create a script so that it automatically clicks an "Add to Cart" button on the webpage once I visit it. An example on the website is the item "". Ive tried using the following script
<script src=".8.0.js"
type="text/javascript">/script>
<script type="text/javascript">
$(function(){
setTimeout(function() {
$("add-to-cart-button").trigger('click');
},1);
});
</script>
But there was no luck. If someone could help me create a script that would automatically click the add to cart button once I visit any item on the website I would be extremely grateful and would even be willing to pay for this script. Oh also im on a mac if it makes a difference.
I'm pletely new to scripting and i'm having an awful time trying to create a script so that it automatically clicks an "Add to Cart" button on the webpage once I visit it. An example on the website is the item "https://www.therealreal./products/women/outerwear/jackets/chanel-jacket-931420". Ive tried using the following script
<script src="http://ajax.aspnetcdn./ajax/jquery/jquery-1.8.0.js"
type="text/javascript">/script>
<script type="text/javascript">
$(function(){
setTimeout(function() {
$("add-to-cart-button").trigger('click');
},1);
});
</script>
But there was no luck. If someone could help me create a script that would automatically click the add to cart button once I visit any item on the website I would be extremely grateful and would even be willing to pay for this script. Oh also im on a mac if it makes a difference.
Share edited Dec 18, 2014 at 5:40 Yagnesh Agola 4,6576 gold badges38 silver badges50 bronze badges asked Dec 18, 2014 at 5:30 IvanIvan 131 gold badge2 silver badges4 bronze badges 2- You lose the sufix selector in JQUERY, you should use the # sharp when is a element in the html with a specific ID, selecting the first element found in the document, eg: To select the "<button ID='btnAddToCart'>" element call to $("#btnAddToCart"). if you want apply functionality or other attributes you can use the "." to select all elements with a specific class, eg: To select the "<li class='listItem'>" element call to $(".listItem") – Eduardo Vélez Commented Dec 18, 2014 at 5:39
- how the item can be selected ? is there any js function or it is direct link to you item ? – Yagnesh Agola Commented Dec 18, 2014 at 5:42
4 Answers
Reset to default 1i think if you follow the idea that i will show, you will catch the solution
consider that you have two buttons one called "Call set time out" and another is your desired button "Add to cart"
and on "Call set time out" click event you want to call "Add to Cart" button event so you should do the following
the html will be
<input type="button" id = "Call-set-time-out" value= "Call set time out" />
<input type="button" id = "add-to-cart-button" value= "Add to cart"/>
and the jquery script will be
$( "#Call-set-time-out" ).click(function() {
$("#add-to-cart-button").trigger('click');
});
$( "#add-to-cart-button" ).click(function() {
alert( "add-to-cart-button .click() event called." );
});
i hope this will help you and good luck for you journey in Jquery world
Try this:
If add-to-cart-button
is ID:
$("#add-to-cart-button").trigger('click');
If add-to-cart-button
is Class:
$(".add-to-cart-button").trigger('click');
I think $("#add-to-cart-button").click(); will work for you based on if add-to-cart-button is id of that button.
Hi try the below code this should help
<script src="http://code.jquery./jquery-1.11.0.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$(".add-to-cart-button").trigger('click');
});
</script>
Happy Coding :)
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744885460a4599090.html
评论列表(0条)