get word click in paragraphs

后端 未结 4 1388
执念已碎
执念已碎 2020-12-06 01:05

I have an HTML document with about 30,000 words in it.

I\'d like to be able to do something when a user clicks any word. For simplicity/concept right now, I\'d just

4条回答
  •  萌比男神i
    2020-12-06 01:31

    I'm a little late to the party I see.

    Try this one out.

    init()
    
    function init()
    {
        addListeners();
        adjustText(document.getElementById("text"));   
    }
    
    function addListeners()
    {
        document.body.onclick = clicked;   
    }
    
    function adjustText(holder)
    {
        text = holder.innerHTML.split(" ");
        holder.innerHTML = "";
        for(var i=0;i

    http://jsfiddle.net/AdwCA/2/

提交回复
热议问题