gpt4 book ai didi

javascript - 如何通过单击javascript更改文本

转载 作者:行者123 更新时间:2023-11-28 03:52:14 26 4
gpt4 key购买 nike

对于一个大学元素,我正在创建一个网页来显示倾斜策略短语(由 Brian Eno 和 Peter Schmidt 创建),编写的代码会在刷新页面时拉出一个随机策略,但是我希望该策略能够单击更改(屏幕上的任何位置)而不是必须刷新页面,任何人都可以帮助我吗?

提前谢谢你。

<body>
<div class="container">
<div class="card fade-in">
<p id="randomStrategy"></p>
<script>

// Establish a variable, which pulls from an array.

var selectStrategy = [



"Abandon desire",
"Abandon normal instructions",
"Accept advice",
"Adding on",
"A line has two sides",
"Always the first steps",
"Ask people to work against their better judgement",
"Ask your body",
"Be dirty",
"Be extravagant",
"Be less critical",
"Breathe more deeply",
"Bridges -build -burn",
"Change ambiguities to specifics",
"Change nothing and continue consistently",
"Change specifics to ambiguities",
"Consider transitions",
"Courage!",
"Cut a vital connection",
"Decorate, decorate",
"Destroy nothing; destroy the most important thing",
"Discard an axiom",
"Disciplined self-indulgence",
"Discover your formulas and abandon them",
"Display your talent",
"Distort time",
"Do nothing for as long as possible",
"Don’t avoid what is easy",
"Don’t break the silence",
"Don’t stress one thing more than another",
"Do something boring",
"Do something sudden, destructive and unpredictable",
"Do the last thing first",
"Do the words need changing?",
"Emphasise differences",
"Emphasise the flaws",
"Faced with a choice, do both (From Dieter Rot.)",
"Find a safe part and use it as an anchor",
"Give the game away",
"Give way to your worst impulse",
"Go outside. Shut the door.",
"Go to an extreme, come part way back",
"How would someone else do it?",
"How would you have done it?",
"In total darkness, or in a very large room, very quietly",
"Is it finished?",
"Is something missing?",
"Is the style right?",
"It is simply a matter or work",
"Just carry on",
"Listen to the quiet voice",
"Look at the order in which you do things",
"Magnify the most difficult details",
"Make it more sensual",
"Make what’s perfect more human",
"Move towards the unimportant",
"Not building a wall; making a brick",
"Once the search has begun, something will be found",
"Only a part, not the whole",
"Only one element of each kind",
"Openly resist change",
"Pae White’s non-blank graphic metacard",
"Question the heroic approach",
"Remember quiet evenings",
"Remove a restriction",
"Repetition is a form of change",
"Retrace your steps",
"Reverse",
"Simple Subtraction",
"Slow preparation, fast execution",
"State the problem as clearly as possible",
"Take a break",
"Take away the important parts",
"The inconsistency principle",
"The most easily forgotten thing is the most important",
"Think -inside the work -outside the work",
"Tidy up",
"Try faking it (From Stewart Brand.)",
"Turn it upside down",
"Use an old idea",
"Use cliches",
"Use filters",
"Use something nearby as a model",
"Use ‘unqualified’ people",
"Use your own ideas",
"Voice your suspicions",
"Water",
"What context would look right?",
"What is the simplest solution?",
"What mistakes did you make last time?",
"What to increase? What to reduce? What to maintain?",
"What were you really thinking about just now?",
"What wouldn’t you do?",
"What would your closest friend do?",
"When is it for?",
"Where is the edge?",
"Which parts can be grouped?",
"Work at a different speed",
"Would anyone want it?",
"Your mistake was a hidden intention",
"Use fewer notes",
"Use filters",
"Use ‘unqualified’ people",
"Water",
"What are you really thinking about just now? Incorporate",
"What is the reality of the situation?",
"What mistakes did you make last time?",
"What would your closest friend do?",
"What wouldn’t you do?",
"Work at a different speed",
"You are an engineer",
"You can only make one dot at a time",
"You don’t have to be ashamed of using your own ideas",
// The following is where the randomness magic happens.
];
var pickAStrategy = function () {
var randomStrategy = selectStrategy[Math.floor(Math.random() *
selectStrategy.length)];
return randomStrategy;
};
// This writes the strategy to the page.

document.getElementById("randomStrategy").innerHTML = pickAStrategy();
</script>
</div> <!-- /card -->
</div> <!-- /container -->
</body>
</html>

最佳答案

你想要这样的东西吗?

var selectStrategy = [
"Abandon desire",
"Abandon normal instructions",
"Accept advice",
"Adding on",
"A line has two sides",
"Always the first steps",
"Ask people to work against their better judgement",
"Ask your body",
"Be dirty",
"Be extravagant",
"Be less critical",
"Breathe more deeply",
"Bridges -build -burn",
"Change ambiguities to specifics",
"Change nothing and continue consistently",
"Change specifics to ambiguities",
"Consider transitions",
"Courage!",
"Cut a vital connection",
"Decorate, decorate",
"Destroy nothing; destroy the most important thing",
"Discard an axiom",
"Disciplined self-indulgence",
"Discover your formulas and abandon them",
"Display your talent",
"Distort time",
"Do nothing for as long as possible",
"Don’t avoid what is easy",
"Don’t break the silence",
"Don’t stress one thing more than another",
"Do something boring",
"Do something sudden, destructive and unpredictable",
"Do the last thing first",
"Do the words need changing?",
"Emphasise differences",
"Emphasise the flaws",
"Faced with a choice, do both (From Dieter Rot.)",
"Find a safe part and use it as an anchor",
"Give the game away",
"Give way to your worst impulse",
"Go outside. Shut the door.",
"Go to an extreme, come part way back",
"How would someone else do it?",
"How would you have done it?",
"In total darkness, or in a very large room, very quietly",
"Is it finished?",
"Is something missing?",
"Is the style right?",
"It is simply a matter or work",
"Just carry on",
"Listen to the quiet voice",
"Look at the order in which you do things",
"Magnify the most difficult details",
"Make it more sensual",
"Make what’s perfect more human",
"Move towards the unimportant",
"Not building a wall; making a brick",
"Once the search has begun, something will be found",
"Only a part, not the whole",
"Only one element of each kind",
"Openly resist change",
"Pae White’s non-blank graphic metacard",
"Question the heroic approach",
"Remember quiet evenings",
"Remove a restriction",
"Repetition is a form of change",
"Retrace your steps",
"Reverse",
"Simple Subtraction",
"Slow preparation, fast execution",
"State the problem as clearly as possible",
"Take a break",
"Take away the important parts",
"The inconsistency principle",
"The most easily forgotten thing is the most important",
"Think -inside the work -outside the work",
"Tidy up",
"Try faking it (From Stewart Brand.)",
"Turn it upside down",
"Use an old idea",
"Use cliches",
"Use filters",
"Use something nearby as a model",
"Use ‘unqualified’ people",
"Use your own ideas",
"Voice your suspicions",
"Water",
"What context would look right?",
"What is the simplest solution?",
"What mistakes did you make last time?",
"What to increase? What to reduce? What to maintain?",
"What were you really thinking about just now?",
"What wouldn’t you do?",
"What would your closest friend do?",
"When is it for?",
"Where is the edge?",
"Which parts can be grouped?",
"Work at a different speed",
"Would anyone want it?",
"Your mistake was a hidden intention",
"Use fewer notes",
"Use filters",
"Use ‘unqualified’ people",
"Water",
"What are you really thinking about just now? Incorporate",
"What is the reality of the situation?",
"What mistakes did you make last time?",
"What would your closest friend do?",
"What wouldn’t you do?",
"Work at a different speed",
"You are an engineer",
"You can only make one dot at a time",
"You don’t have to be ashamed of using your own ideas",
];

var pickAStrategy = function () {
var randomStrategy = selectStrategy[Math.floor(Math.random() * selectStrategy.length)];
document.getElementById('randomStrategy').innerHTML = randomStrategy;
};

pickAStrategy();
document.addEventListener('click', pickAStrategy, true);
<div class="container">
<div class="card fade-in">
<p id="randomStrategy"></p>
</div>
</div>

关于javascript - 如何通过单击javascript更改文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43668349/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com