How to bind click event on image added using CSS 'background-image' property in jQuery

后端 未结 4 1324
南旧
南旧 2021-02-04 06:40

Here is my fiddle link

I guess my question is clear by title itself. Still, what I am looking for is an way to bind click event on the image added using css

4条回答
  •  灰色年华
    2021-02-04 07:05

    I do something similar by using an immediately followed by an

    The button is given a background image and positioned-relative to move it into the text field; essentially...

    position: relative;
    top: 4px;
    right: 1.6em;
    height: 16px;
    width: 16px;
    border: none;
    

    Then I just add a dead-plain click handler to the button, no computations necessary.

    The height x width would depend on your image, and you would tweak the top and right to fit your situation.

    This fiddle shows it pared down to the bare essentials.

提交回复
热议问题