Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

open div with onClick element position

function Example() {
  const [count, setCount] = useState(0);
  const [buttonPosition,setButtonPosition] = useState({
  xAxis:" ",
  yAxis:" "
  })
  
  const dataValue = (event) => {
         setButtonPosition({...buttonPosition,xAxis:event.target.offsetLeft,yAxis:event.target.offsetTop})
  }

  return (
  <div>
   <div style={{height:"50px",width:"50px",border:"1px solid gray",alignItem:"center", textAlign:"center",verticleAlign:"center",position:"absolute",left:buttonPosition.xAxis,top:buttonPosition.yAxis+23}}>
       data
   </div>
  <div style={{display:"flex",flexDirection:"column",gap:"65px"}}>
    <div style={{display:"flex",gap:"7px"}}>
      <button onClick={(e) => dataValue(e)} className="first"> click 1</button>
       <button onClick={(e) => dataValue(e)} className="second" > click 2</button>
        <button onClick={(e) => dataValue(e)} className="third" > click 3</button>
         <button onClick={(e) => dataValue(e)} style={{width:"70px"}}> click 4</button>
          <button onClick={(e) => dataValue(e)}> click 5</button>
    </div>
    
     <div style={{display:"flex",gap:"7px"}}>
      <button onClick={(e) => dataValue(e)} > click 1</button>
       <button onClick={(e) => dataValue(e)}> click 2</button>
        <button onClick={(e) => dataValue(e)}> click 3</button>
         <button onClick={(e) => dataValue(e)}> click 4</button>
          <button onClick={(e) => dataValue(e)}> click 5</button>
    </div>
    </div>
   </div>
  );
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: Creating Variables In Self Evoking Function 
Javascript :: using parseint in javascript 
Javascript :: javascript get multiple attributes 
Javascript :: online jquery converter 
Javascript :: convert pcap fiole to json tshark 
Javascript :: how to send token in get request vue js 
Javascript :: Uncaught Error: spawn node 
Javascript :: Creating A Promise With JSON 
Javascript :: phaser wrap group 
Javascript :: jquery attrib 
Javascript :: for in loop of javascript 
Javascript :: counter using redux 
Javascript :: javascript quotes 
Javascript :: What Is A Closure: Informal Explanation 
Javascript :: ...args javascript 
Javascript :: 20 most common question in javascript 
Javascript :: what does the symbol function do in javascript 
Javascript :: true type of javascript 
Javascript :: how to store new object made by constructor classes data in local storage using javascript 
Javascript :: mul function call to 3 functions 
Javascript :: Deployment of react static page using node and express 
Javascript :: Backbone Set Model In View 
Javascript :: Backbone Template Simple Example 
Javascript :: get number of new document firebasse 
Javascript :: javascript asynchronous function list 
Javascript :: javascript filter array of object by id 
Javascript :: react native new project 
Javascript :: emoji picker react 
Javascript :: custom hook react 
Javascript :: run function periodically with setInterval 
ADD CONTENT
Topic
Content
Source link
Name
4+2 =