Can I make an svg image button?

后端 未结 5 1049
轻奢々
轻奢々 2020-12-25 14:11

Is there any way of making a POST request when an svg image is clicked?

My best attempt so far looks like:

5条回答
  •  半阙折子戏
    2020-12-25 14:56

    This is a simple button with a lightning inside the box.

     
                    
                        
                            
                        
                        
                         
        
    

    and here is the script for the fucntion when you click

    function Flash(){
    // post whatever you want inside here
    
    }
    

    The problem when you create a button and inside it has lines and when you put to the parent element the onclick you don't click all the svg element but you click separately and all children inside. so you need to create a rect inside the svg with the width and the height of the parent element and hide it, and after put there the onclick!

提交回复
热议问题