简体   繁体   中英

How do I add a cookie onclick of a button in Drupal7?

I have an article (Full Html) and I have a button. I want, when the button is clicked, to create a cookie and remember that the button is clicked. This is the code I currently have:

<button id="test" value="test" onclick="Press()">Press</button>

<script>

function Press() { text
}
</script>

How should I create the press function? This is the HTML of the article

function Press() { 
     document.cookie="button=pressed";
}

document.cookie will create a cookie..

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