私はjavascriptにかなり慣れていません。以下は私のjavascriptコードです。いくつかのクリック可能なクラスがありますid
。例:
<a href="#" id="15" class="firefly-button lfloat"><div class="contentBoxes captionfull">
ユーザーがそれをクリックした場合、変数をとして保存したいと思います"showf15"
。 ["show"+first-character of clicked-class+id]
これを達成するために、私は次の行を書きました:
c = "show"+$(this).charAt(0)+this.id;
私のjvascriptコードは次のとおりです。
$(function () {
$(".primavera-button, .lectures-button, .firefly-button, .argentum-button, .workshops-button, .exhibitions-button").click(function (e) {
c = "show"+$(this).charAt(0)+this.id;
e.stopPropagation();
$.ajax({
type: "POST",
url: "../fetchevents.php",
dataType: "json",
data: {
id: c
},
....
ただし、機能していないようです。
変数などを取得できる場合c
、showl15
データベーステーブルにはc
= idを持つテキストデータが含まれており、結果としてjsonで取得できます。