I've this code: <input class="button tagadd" value="Add" tabindex="3" type="button"> This button calls a JavaScript Function, but that JavaScript Function is hidden. Actually it calls an ajax function. This is a Wordpress Add Tag button code & there is no "id" attribute :S I want to call that hidden function to click on it. Is there any way to call that hidden function. I tried .click(); function, but it doesn't work :s Please help
My one works like this <script type="text/javascript"> $(document).ready(function(){ $('#printbuttoncustomer').trigger('click'); }); </script> <input name="printbuttoncustomer" id="printbuttoncustomer" type="hidden" /><div id="iframeplaceholdercustomer"></div> Code (markup):
tried making it: <input class="button tagadd" value="Add" tabindex="3" type="button" id="btn1"> and: <script type="text/javascript"> document.getElementById("btn1").click(); //OR document.getElementById("btn1").onclick(); <script> Code (markup):
Thanks for reply friend. But the problem is that! there is no id set on div where i want to apply my code. It's a wordpress theme code. This is the code: <input class="button tagadd" value="Add" tabindex="3" type="button"> Code (markup): When i click on this input button, an hidden function calls, but i can't find that function. Wordpress hide that function in it's library. I Just want to click on this input button from javascript function without mouse click on this input button. But i'm sure that this input button call an ajax function. I'm pasting here some of extracted code. HTML CODE <div class="tagsdiv" id="post_tag"> <div class="jaxtag"> <div class="nojs-tags hide-if-js"> <p>Add or remove tags</p> <textarea name="tax_input[post_tag]" class="the-tags" id="tax-input[post_tag]"></textarea></div> <div class="ajaxtag hide-if-no-js"> <label class="screen-reader-text" for="new-tag-post_tag">Post Tags</label> <div class="taghint">Add new tag</div> <input id="new-tag-post_tag" name="newtag[post_tag]" class="newtag form-input-tip" size="16" autocomplete="off" value="" type="text"> <input class="button tagadd" value="Add" tabindex="3" type="button"> </div></div> <p class="howto">Separate tags with commas.</p> <div class="tagchecklist"></div> </div> <p class="hide-if-no-js"><a href="#titlediv" class="tagcloud-link" id="link-post_tag">Choose from the most used tags in Post Tags</a></p> </div> Code (markup): SOME EXTRACTED JAVASCRIPT CODE var tagBox,commentsBox,editPermalink,makeSlugeditClickable,WPSetThumbnailHTML,WPSetT humbnailID,WPRemoveThumbnail; function array_unique_noempty(b) { var c=[]; jQuery.each(b,function(a,d) { d=jQuery.trim(d); if(d&&jQuery.inArray(d,c)==-1) { c.push(d) } }); return c; }(function(a){tagBox={clean:function(b){return b.replace(/\s*,\s*/g,",").replace(/,+/g,",").replace(/[,\s]+$/,"").replace(/^[,\s]+/,"")},parseTags:function(e){var h=e.id,b=h.split("-check-num-")[1],d=a(e).closest(".tagsdiv"),g=d.find(".the-tags"),c=g.val().split(","),f=[]; delete c[b]; a.each(c,function(i,j){j=a.trim(j); if(j){f.push(j)}}); g.val(this.clean(f.join(","))); this.quickClicks(d); return false},quickClicks:function(c){var e=a(".the-tags",c),d=a(".tagchecklist",c),b; if(!e.length){return}b=e.val().split(","); d.empty(); a.each(b,function(h,i){var f,g,j=a(c).attr("id"); i=a.trim(i); if(!i.match(/^\s+$/)&&""!=i) { g=j+"-check-num-"+h; f='<span><a id="'+g+'" class="ntdelbutton">X</a> '+i+"</span> "; d.append(f); a("#"+g).click(function() { tagBox.parseTags(this); }) } })},flushTags:function(e,b,g){b=b||false; var i,c=a(".the-tags",e),h=a("input.newtag",e),d; i=b?a(b).text():h.val(); tagsval=c.val(); d=tagsval?tagsval+","+i:i; d=this.clean(d); d=array_unique_noempty(d.split(",")).join(","); c.val(d); this.quickClicks(e); if(!b){h.val("")}if("undefined"==typeof(g)){h.focus()}return false},get:function(c){var b=c.substr(c.indexOf("-")+1); a.post(ajaxurl,{action:"get-tagcloud",tax:b},function(e,d){if(0==e||"success"!=d){e=wpAjax.broken}e=a('<p id="tagcloud-'+b+'" class="the-tagcloud">'+e+"</p>"); a("a",e).click(function(){tagBox.flushTags(a(this).closest(".inside").children(".tagsdiv"),this); return false}); a("#"+c).after(e)})},init:function(){var b=this,c=a("div.ajaxtag"); a(".tagsdiv").each(function(){tagBox.quickClicks(this)}); a("input.tagadd",c).click(function(){b.flushTags(a(this).closest(".tagsdiv"))}); a("div.taghint",c).click(function(){a(this).css("visibility","hidden").siblings(".newtag").focus()}); a("input.newtag",c).blur(function() { if(this.value=="") { a(this).siblings(".taghint").css("visibility","") } }).focus(function() { a(this).siblings(".taghint").css("visibility","hidden") }).keyup(function(d) { if(13==d.which) { tagBox.flushTags(a(this).closest(".tagsdiv")); return false; } }).keypress(function(d) { if(13==d.which){ d.preventDefault(); return false; } }).each(function() { var d=a(this).closest("div.tagsdiv").attr("id"); a(this).suggest(ajaxurl+"?action=ajax-tag-search&tax="+d,{delay:500,minchars:2,multiple:true,multipleSep:", "}) }); a("#post").submit(function(){ a("div.tagsdiv").each(function() { tagBox.flushTags(this,false,1) }) }); Code (markup): It's really a challenge for me. I simply just want to auto add my tags on input fields and then want to click on input button, then submit. I can auto set tags in input field, and can auto submit form. But i can't auto click on add tags button without mouse click on input button. Please Help.
There is a line there, expanded here as follows: You or the author might have changed the default $() or jQuery() into a()? So mimicking above function, following simple code (as you have said) would solve the problem: $("input.tagadd").click(); Code (markup): But if not, I guess you have to dig in using a DOM Inspector, find the element and see what function installed on "click" event
do we get them online. I want to insert this kind of button to my website. Just like the www.invox.com giving the services. I want some more websites.