简体   繁体   中英

How to put multiple parameters into onClick attribute

I was wondering how to put multiple parameters into onClick so you can run one parameter first and the other parameter next.

 <p id='demo'> </p> <a onClick="myWindow.resizeBy(250, 250); document.getElementById('demo').innerHTML = 'Paragraph changed;';"> Click this for a change </a>

Your question is very broad and unclear. Can you provide a code example or a diagram?

Maybe, if you only want to call two seperate functions in sequence:

... onClick="runActions()"...

function runActions() {
  // first function you want to call
  console.log("Hello, World!");
  // second
  alert("Bye!");
}

EDIT:

try this:

<a onClick="changeWindow()">
Click this for a change
</a>
function changeWindow() {
  myWindow.resizeBy(250, 250);
  document.getElementById('demo').innerHTML = 'Paragraph changed!';
}

$('#element').on("click",function (){alert("hello");document.location="/path you want to redirect" }); You can use jQuery. Like you can add more functionality..

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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