如何在窗口提示符下使用mathjax? [英] How do I use mathjax with a window prompt?

查看:119
本文介绍了如何在窗口提示符下使用mathjax?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用MathJax来显示一些用LaTex编写的数学。我已将MathJax脚本()放在标题中,因此当网页首次启动时,所有内容都会正常加载。但我需要能够将此脚本与屏幕按钮一起使用,而不是仅在标题中使用,因此它将显示在网站初始加载后写入的LaTex。



这是我创建的按钮的代码,提示用户,这是我试图放置脚本的地方(不要介意它说myFavouriteColour):



I'm trying to use MathJax to display some math that's been written in LaTex. I've put the MathJax script ( ) in the header, so everything loads just fine when the webpage first starts. But I need to be able to use this script with an onscreen button, rather than only in the header, so it will display LaTex that's been written after the site initially loads.

Here's the code for a button I've created that prompts the user, which is where I'm trying to put the script (don't mind that it says "myFavouriteColour"):

<p id="favouriteColour"></p>

function myFavouriteColour() {
    var colour = prompt("Enter your favourite maths!", "2x^3");
    if (colour != null) {
        document.getElementById("favouriteColour").innerHTML = "$$" + colour + "$$";
        alert(colour);
    }
}





我的尝试:



我已经尝试过以几种方式输入MathJax脚本。它通常只是打破窗口提示。这是其中之一:





What I have tried:

I've already tried putting in the MathJax script in a few ways. It usually just breaks the window prompt. Here's one of them:

<script>
function myFavouriteColour() {
    var colour = prompt("Enter your favourite maths!", "2x^3");
    if (colour != null) {
        document.getElementById("favouriteColour").innerHTML = "$$" + colour + "$$";
        alert(colour);
        script.src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/latest.js?config=TeX-MML-AM_CHTML"
    }
}

推荐答案

+ color +


;
alert(颜色) );
}
}
"; alert(colour); } }





我的尝试:



我已经尝试过以几种方式输入MathJax脚本。它通常会打破窗口提示。这是其中之一:





What I have tried:

I've already tried putting in the MathJax script in a few ways. It usually just breaks the window prompt. Here's one of them:

<script>
function myFavouriteColour() {
    var colour = prompt("Enter your favourite maths!", "2x^3");
    if (colour != null) {
        document.getElementById("favouriteColour").innerHTML = "


+ color +


这篇关于如何在窗口提示符下使用mathjax?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆