Home > front end >  Js how to replace the selected area input box
Js how to replace the selected area input box

Time:09-23

Now in the online examination system, is how to draw the selected text to replace the input box, finally click the button to generate the test question?

5 + 3=8, for example, selected 8 after replacing the input box

CodePudding user response:

You give 8 a label & lt; Span> To span a click event, click span to span, $(" span "). The HTML (' & lt; Input type="text"/& gt; ');

CodePudding user response:

Input box which is not necessarily, also can is 3

CodePudding user response:

The selected here what do you mean? A little ambiguity


The selected text in the selected event in the container to some container such as state, cookies, etc., and then click on the button event is triggered when the take out these values, assigned to a container, you said

CodePudding user response:

refer to the third floor is a little small lewd honest reply:
what meaning of the selected here a little ambiguity


The selected text in the selected event in the container to some container such as state, cookies, etc., and then click on the button event is triggered when the take out these values, assigned to a container, you said


Such as & lt; Span style='font - size: 4 px & gt; Asfsfsdfs How to remove & lt; Span> And & lt;/span> , leaving only asfsfsdfs text

CodePudding user response:

reference 4 floor snlixing response:
Quote: refer to the third floor is a little small lewd honest reply:

The selected here what do you mean? A little ambiguity


The selected text in the selected event in the container to some container such as state, cookies, etc., and then click on the button event is triggered when the take out these values, assigned to a container, you said


Such as & lt; Span style='font - size: 4 px & gt; Asfsfsdfs How to remove & lt; Span> And & lt;/span> Text, leaving only asfsfsdfs
approach has a lot of roughly idea is
Use the selector to choose you to operate, then string manipulation
The document

reference 4 floor snlixing response:
Quote: refer to the third floor is a little small lewd honest reply:

The selected here what do you mean? A little ambiguity


The selected text in the selected event in the container to some container such as state, cookies, etc., and then click on the button event is triggered when the take out these values, assigned to a container, you said


Such as & lt; Span style='font - size: 4 px & gt; Asfsfsdfs How to remove & lt; Span> And & lt;/span> Text, leaving only asfsfsdfs
 
<script type="text/javascript">
The function getcontent () {

Var=tt document. GetElementById (' app '.) innerHTML;
Var startspantaga=tt. IndexOf (' & lt; Span ');//span starting position this parameter temporarily useless
Var startspantagb=tt. IndexOf (' & gt; ');//start span end position
Var endspantag=tt. IndexOf (' & lt;/span> ');//end span label position
Var value=https://bbs.csdn.net/topics/tt.substring (startspantagb + 1, endspantag);
Alert (value);
}
</script>
<body>
This is a title.
  • Related