Font Awesome icons innerHTML

时间:2017-08-30 20:37:00

标签: javascript html icons font-awesome

I need to be able to put the icons into the innerHTML, but for some reason they aren't showing up.

The page is just showing little squares, which means that the code is invalid, so what is the correct code? I can't use the i tags because they have quotation marks: "" in the to show the class name and the true property for aria-hidden.

Unable to import module 'index': Error
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
Your Lambda function "testprojectx" cannot be edited inline since the file name specified in the handler does not match a file name in your deployment package.

3 个答案:

答案 0 :(得分:3)

You need to add the JButton clearMessageButton = new JButton(new AbstractAction("Test Result") { @Override public void actionPerformed(ActionEvent arg0) { SwingWorker worker = new SwingWorker() { @Override protected Object doInBackground() throws Exception { loaderLabel1.setVisible(true); TestMethod(); return true; } public void TestMethod() { System.out.println(" =========START TestMethod ========="); try { Thread.currentThread().sleep(10000); } catch (InterruptedException e) { e.printStackTrace(); } System.out.println(" =========complete TestMethod ========="); } protected void done() { loaderLabel1.setVisible(false); }; }; worker.execute(); } }); class:

select * from table where '+92 343 9879098' like '%' || number || '%';
    String search = "+92 343 9879098";
    String query = "select * from table where ";
    String[] parts = search.split( "\\s+" );
    for ( String oneNumber : parts ) {
        query += " number like '%" +oneNumber+ "%' OR";
    }
    query += " false"; // this, or trim the last OR calculating the string length

That class handle the font that should be used to display the content. Without specifying the relevant font the browser will not display the relevant icon.

答案 1 :(得分:2)

您正在获取正方形,因为您的unicode实体不会以您的默认浏览器字体存在。

&安培;#xf296;不是有效的unicode字符。它创建了这个:见http://www.fileformat.info/info/unicode/char/f296/index.htm

&安培;#xf113;不是有效的unicode字符。它创造了这个:

&安培;#xf281;不是有效的unicode字符。它创造了这个:

您知道,有两种不同类型的引号,它们通常可以相互包含在一起,因此string = "Say 'Hello' to my little friend."在大多数编程语言中都是可接受的字符串。

除非您尝试对源代码进行模糊处理,这不是您原始问题的一部分,请尝试以下操作:

<script>

document.getElementById("quizQ").innerHTML =
    "<h3>which icon is used for github?</h3><br>"
    + "<i class='fa fa-gitlab' aria-hidden='true'></i><br>"
    + "<i class='fa fa-rub' aria-hidden='true'></i><br>"
    + "<i class='fa fa-github' aria-hidden='true'></i>"

</script>

答案 2 :(得分:0)

I believe it is, because the font-awesome icons consist of 2 css classes: XmlSerializationProject & Test. The symbols you're using probably corresponds with the second, but not the first.

I'd suggest adding using System; using System.IO; using System.Text; using System.Xml; using System.Xml.Serialization; namespace XmlSerializationProject { class Program { static void Main(string[] args) { // Create test details array var TestDetails = new Xml.Detail[] { new Xml.Detail { Description = "bald" }, new Xml.Detail { Description = "red tie" } }; // create test person object that holds details array var TestBar = new Xml.Person() { Details = TestDetails }; // serialize the person object var s = new Xml.Serializer(); var TestOutput = s.Serialize(TestBar); Console.WriteLine(TestOutput); Console.ReadKey(); } } // base classes public abstract class Person { public abstract Detail[] Details { get; set; } } public abstract class Detail { public abstract string Description { get; set; } } namespace Xml { [Serializable] [XmlType(AnonymousType = true)] [XmlRoot(IsNullable = false)] public class Person : XmlSerializationProject.Person { public Person() { } public Person(XmlSerializationProject.Person person) { // Deep copy if (person.Details == null) return; this.Details = new Detail[person.Details.Length]; for (int i = 0; i < person.Details.Length; i++) { this.Details[i] = new Detail { Description = person.Details[i].Description }; } } [XmlArray(ElementName = "Details")] [XmlArrayItem("Detail", typeof(Detail))] [XmlArrayItem("ODetail", typeof(XmlSerializationProject.Detail))] public override XmlSerializationProject.Detail[] Details { get; set; } } [Serializable] public class Detail : XmlSerializationProject.Detail { public override string Description { get; set; } } // class that does serializing work public class Serializer { private static readonly XmlSerializer PersonSerializer; private static Serializer() { var xmlAttributeOverrides = new XmlAttributeOverrides(); // Change original "Detail" class's element name to "AbstractDetail" var xmlAttributesOriginalDetail = new XmlAttributes(); xmlAttributesOriginalDetail.XmlType = new XmlTypeAttribute() { TypeName = "AbstractDetail" }; xmlAttributeOverrides.Add(typeof(XmlSerializationProject.Detail), xmlAttributesOriginalDetail); // Ignore Person.Details array var xmlAttributesOriginalDetailsArray = new XmlAttributes(); xmlAttributesOriginalDetailsArray.XmlIgnore = true; xmlAttributeOverrides.Add(typeof(XmlSerializationProject.Person), "Details", xmlAttributesOriginalDetailsArray); PersonSerializer = new XmlSerializer( typeof(Person), xmlAttributeOverrides, new Type[] { typeof(Detail) }, new XmlRootAttribute(), "default"); } public string Serialize(XmlSerializationProject.Person person) { return Serialize(new Person(person)); } public string Serialize(Person person) { string Output = null; var Stream = new MemoryStream(); var Encoding = new UTF8Encoding(false, true); using (var Writer = new XmlTextWriter(Stream, Encoding)) { Writer.Formatting = Formatting.Indented; PersonSerializer.Serialize(Writer, person); Output = Encoding.GetString(Stream.ToArray()); } Stream.Dispose(); return Output; } } } } to your li's. If that doesn't work, consider the suggested setup: fa