The code snippet in Javascript below is designed to execute the function doSomethingWithSelectedText
, which verifies if any text is currently selected by utilizing the function getSelectedObj
.
The getSelectedObj
function returns an object that contains information about the selected text.
An issue arises where the #text div updates with each text selection, and the #search div opens a new Google tab searching for the highlighted/selected text. However, the updating stops after the initial selection.
The probable cause could be that the addEventListener
is implemented within the if()
statement of the mouseup
event, which prevents it from being updated further. How to address this dilemma remains uncertain.
index.html
<div id="popup">
<div id ="text"></div>
<div id="search" class="fa fa-search"></div>
<div id="save" class="fa fa-file"></div>
</div>
styles.css
#popup{
display: none;
background-color: orange;
color: white;
position: absolute;
z-index: 1000;
width:100px;
height: 50px;
}
#search,#save {
display: inline-block;
padding: 15px;
font-size: 20px;
}