Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I want to add parameters in div element with React

Tags:

reactjs

I want to add parameters in div element with React.

This code not working:

function Slider() {

  const bg1 =' data-background="images/slider/slider1.jpg"';

  return (<>

    <div className="slider-area over-hidden" {bg1}></div>

    );
}
like image 247
suf yan Avatar asked Dec 07 '25 11:12

suf yan


1 Answers

I create an object with the parameter.

const bg1 = {
    "data-background": "image/slider/slider1.jpg"
}

<div className="slider-area over-hidden" {...bg1}></div>
like image 178
Someone Special Avatar answered Dec 09 '25 02:12

Someone Special



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!